Created
April 14, 2014 21:00
-
-
Save darrelmiller/10682407 to your computer and use it in GitHub Desktop.
Create Owin host from HttpListener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IDisposable CreateHttpListenerServer(Uri baseAddress, Func<IDictionary<string, object>, Task> appFunc) | |
{ | |
var props = new Dictionary<string, object>(); | |
var address = Address.Create(); | |
address.Host = baseAddress.Host; | |
address.Port = baseAddress.Port.ToString(); | |
address.Scheme = baseAddress.Scheme; | |
address.Path = baseAddress.AbsolutePath; | |
props["host.Addresses"] = new List<IDictionary<string, object>> { address.Dictionary }; | |
OwinServerFactory.Initialize(props); | |
var server = OwinServerFactory.Create(appFunc, props); | |
return server; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment