public virtual async Task StartAsync <TContext>(IHttpApplication <TContext> application, CancellationToken cancellationToken) { CreateOwinProps(application, out Func <IDictionary <string, object>, Task> appFunc, out Dictionary <string, object> props); OwinServerFactory.Initialize(props); _HttpListenerServer = OwinServerFactory.Create(appFunc, props); }
public static IDisposable CreateHttpListenerServer(List <Uri> baseAddresses, Func <IDictionary <string, object>, Task> appFunc) { var props = new Dictionary <string, object>(); var addresses = baseAddresses.Select(baseAddress => new Dictionary <string, object>() { { "host", baseAddress.Host }, { "port", baseAddress.Port.ToString() }, { "scheme", baseAddress.Scheme }, { "path", baseAddress.AbsolutePath } }).Cast <IDictionary <string, object> >().ToList(); props["host.Addresses"] = addresses; //props["server.LoggerFactory"] = LoggerFunc goes here; OwinServerFactory.Initialize(props); return(OwinServerFactory.Create(appFunc, props)); }
private IDisposable CreateListener(int port) { var appProperties = new AppProperties(new Dictionary <string, object>()) { Addresses = AddressCollection.Create() }; var address = Address.Create(); address.Scheme = "http"; address.Host = "localhost"; address.Port = port.ToString(); address.Path = "/sonarlint/api/"; appProperties.Addresses.Add(address); // Create a new Owin HTTPListener that forwards all requests to our processor for handling. return(OwinServerFactory.Create(requestProcessor.ProcessRequest, appProperties.Dictionary)); }
private static void Main(string[] args) { var properties = new Dictionary <string, object> { { "host.Addresses", new [] { new Dictionary <string, object> { { "port", "1337" }, { "host", "localhost" } } as IDictionary <string, object> }.ToList() } }; //var server = Server.AppFuncServer(); var server = Server.MiddlewareFuncServer(); var cancelWait = new ManualResetEvent(false); Console.CancelKeyPress += (sender, e) => { cancelWait.Set(); }; using (OwinServerFactory.Create(server, properties)) { Console.WriteLine("Listening on http://localhost:1337"); cancelWait.WaitOne(); } }
public void Start <TContext>(IHttpApplication <TContext> application) { Func <IDictionary <string, object>, Task> appFunc = async env => { FeatureCollection features = new FeatureCollection(new OwinFeatureCollection(env)); TContext context = application.CreateContext(features); try { await application.ProcessRequestAsync(context); } catch (Exception ex) { application.DisposeContext(context, ex); throw; } application.DisposeContext(context, null); }; appFunc = OwinWebSocketAcceptAdapter.AdaptWebSockets(appFunc); Dictionary <string, object> props = new Dictionary <string, object> { ["host.Addresses"] = Features.Get <IServerAddressesFeature>() .Addresses.Select(add => new Uri(add)) .Select(add => new Address(add.Scheme, add.Host, add.Port.ToString(), add.LocalPath).Dictionary) .ToList() }; OwinServerFactory.Initialize(props); _HttpListenerServer = OwinServerFactory.Create(appFunc, props); }
public Func <IDisposable> Build() { return(() => OwinServerFactory.Create(c => RunMiddleware(Middleware.ToArray(), c), Properties)); }
public void CreateEmptyProperties_Success() { OwinServerFactory.Create(_notImplemented, new Dictionary <string, object>()); }
public void CreateNullProperties_Throws() { Assert.Throws <ArgumentNullException>(() => OwinServerFactory.Create(_notImplemented, null)); }
public void CreateNullAppFunc_Throws() { Assert.Throws <ArgumentNullException>(() => OwinServerFactory.Create(null, new Dictionary <string, object>())); }