public static string Start(EditorSessionManager mgr, CancellationToken cancel, int port = 0) { var host = new WebHostBuilder() .UseKestrel() .UseUrls($"http://localhost:{port}/") .UseStartup <Startup>() .UseContentRoot(Directory.GetCurrentDirectory()) .ConfigureServices(sc => sc.AddSingleton(mgr)) .Build(); host.Start(); var addr = host.ServerFeatures.Get <IServerAddressesFeature>(); Log.Message($"Web listening on {string.Join(", ", addr.Addresses)}"); cancel.Register(() => { host.StopAsync().Wait(); }); return(addr.Addresses.First()); }
public PreviewerMiddleware(RequestDelegate next, EditorSessionManager mgr) { _next = next; _mgr = mgr; }