You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Framework/Connected.Instance/ServerStartup.cs

47 lines
1.1 KiB

2 years ago
using Connected.Annotations;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Net.Http.Headers;
[assembly: MicroService(MicroServiceType.Sys)]
namespace Connected.Instance
{
[Priority(int.MaxValue)]
internal sealed class ServerStartup : Startup
{
protected override void OnConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddSignalR();
services.AddHttpClient();
services.AddLogging();
services.AddAntiforgery();
services.AddCors((o) =>
{
o.AddDefaultPolicy(new Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicy
{
IsOriginAllowed = (a) => { return true; },
Headers = { HeaderNames.ContentType, HeaderNames.ContentEncoding, HeaderNames.XRequestedWith, "x-signalr-user-agent" }
});
});
}
protected override void OnConfigure(WebApplication app)
{
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
app.UseHttpsRedirection();
}
app.UseCors();
app.UseRouting();
}
}
}