public void Restart() { _server.Dispose(); _server = WebApp.Start(Url, app => { Initializer.ConfigureRoutes(app, Resolver); }); }
public void Configuration(IAppBuilder app) { var corsPolicy = new CorsPolicy() { AllowAnyHeader = true, AllowAnyMethod = true, AllowAnyOrigin = true, SupportsCredentials = true, }; app.UseErrorPage(); // Enable CORS so Karma works app.UseCors(new CorsOptions() { PolicyProvider = new CorsPolicyProvider() { PolicyResolver = context => Task.FromResult(corsPolicy), } }); Initializer.ConfigureRoutes(app, GlobalHost.DependencyResolver, AzureSignalRConnectionString); app.Use((context, next) => { if (context.Request.Path.StartsWithSegments(new PathString("/status"))) { context.Response.StatusCode = 200; return(Task.CompletedTask); } return(next()); }); app.Use(async(context, next) => { if (context.Request.Path.StartsWithSegments(new PathString("/js/server-info.js"))) { // Inject server settings in to the javascript context.Response.StatusCode = 200; context.Response.ContentType = "application/javascript"; await context.Response.WriteAsync($"window._server = {{ azureSignalR: {(string.IsNullOrEmpty(AzureSignalRConnectionString) ? "false" : "true")} }}"); } else { await next(); } }); app.UseFileServer(new FileServerOptions() { EnableDefaultFiles = true, FileSystem = new PhysicalFileSystem(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")), }); }
public void Configuration(IAppBuilder app) { var corsPolicy = new CorsPolicy() { AllowAnyHeader = true, AllowAnyMethod = true, AllowAnyOrigin = true, SupportsCredentials = true, }; // Enable CORS so Karma works app.UseCors(new CorsOptions() { PolicyProvider = new CorsPolicyProvider() { PolicyResolver = context => Task.FromResult(corsPolicy), } }); Initializer.ConfigureRoutes(app, GlobalHost.DependencyResolver); app.Use((context, next) => { if (context.Request.Path.StartsWithSegments(new PathString("/status"))) { context.Response.StatusCode = 200; return(Task.CompletedTask); } return(next()); }); // Valid redirect chain // Overload detection doesn't like it when we use this as an extension method AppBuilderUseExtensions.Use(app, CreateRedirector("/redirect", "/redirect2")); AppBuilderUseExtensions.Use(app, CreateRedirector("/redirect2", "/redirect3")); AppBuilderUseExtensions.Use(app, CreateRedirector("/redirect3", "/redirect4")); AppBuilderUseExtensions.Use(app, CreateRedirector("/redirect4", "/signalr")); // Looping redirect chain AppBuilderUseExtensions.Use(app, CreateRedirector("/redirect-loop", "/redirect-loop2")); AppBuilderUseExtensions.Use(app, CreateRedirector("/redirect-loop2", "/redirect-loop")); // Wrong protocol version AppBuilderUseExtensions.Use(app, CreateRedirector("/redirect-old-proto", "/signalr", protocolVersion: "1.5")); app.UseFileServer(new FileServerOptions() { EnableDefaultFiles = true, FileSystem = new PhysicalFileSystem(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")) }); }
public override void Initialize(int?keepAlive = -1, int?connectionTimeout = 110, int?disconnectTimeout = 30, int?transportConnectTimeout = 5, bool enableAutoRejoiningGroups = false, MessageBusType messageBusType = MessageBusType.Default) { base.Initialize(keepAlive, connectionTimeout, disconnectTimeout, transportConnectTimeout, enableAutoRejoiningGroups, messageBusType); _host.Configure(app => { Initializer.ConfigureRoutes(app, Resolver); }); }
public override void Initialize(int?keepAlive = -1, int?connectionTimeout = 110, int?disconnectTimeout = 30, int?transportConnectTimeout = 5, int?maxIncomingWebSocketMessageSize = 64 * 1024, bool enableAutoRejoiningGroups = false, MessageBusType messageBusType = MessageBusType.Default) { base.Initialize(keepAlive, connectionTimeout, disconnectTimeout, transportConnectTimeout, maxIncomingWebSocketMessageSize, enableAutoRejoiningGroups, messageBusType); _server = WebApp.Start(Url, app => { Initializer.ConfigureRoutes(app, Resolver); }); }
public void Configuration(IAppBuilder app) { var corsPolicy = new CorsPolicy() { AllowAnyHeader = true, AllowAnyMethod = true, AllowAnyOrigin = true, SupportsCredentials = true, }; // Enable CORS so Karma works app.UseCors(new CorsOptions() { PolicyProvider = new CorsPolicyProvider() { PolicyResolver = context => Task.FromResult(corsPolicy), } }); Initializer.ConfigureRoutes(app, GlobalHost.DependencyResolver); app.Use((context, next) => { if (context.Request.Path.StartsWithSegments(new PathString("/status"))) { context.Response.StatusCode = 200; return(Task.CompletedTask); } return(next()); }); app.UseFileServer(new FileServerOptions() { EnableDefaultFiles = true, FileSystem = new PhysicalFileSystem(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")) }); }