mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-03-15 14:51:21 +00:00
64 lines
2 KiB
C#
64 lines
2 KiB
C#
|
using FSO.Server.Common;
|
|||
|
using Microsoft.AspNetCore.Builder;
|
|||
|
using Microsoft.AspNetCore.Hosting;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using Microsoft.Extensions.Configuration;
|
|||
|
using Microsoft.Extensions.DependencyInjection;
|
|||
|
|
|||
|
namespace FSO.Server.Api.Core
|
|||
|
{
|
|||
|
public class Startup : IAPILifetime
|
|||
|
{
|
|||
|
public IApplicationLifetime AppLifetime;
|
|||
|
|
|||
|
public Startup(IConfiguration configuration)
|
|||
|
{
|
|||
|
Configuration = configuration;
|
|||
|
}
|
|||
|
|
|||
|
public IConfiguration Configuration { get; }
|
|||
|
|
|||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|||
|
public void ConfigureServices(IServiceCollection services)
|
|||
|
{
|
|||
|
services.AddCors(options =>
|
|||
|
{
|
|||
|
options.AddDefaultPolicy(
|
|||
|
builder =>
|
|||
|
{
|
|||
|
|
|||
|
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().WithExposedHeaders("content-disposition");
|
|||
|
});
|
|||
|
|
|||
|
options.AddPolicy("AdminAppPolicy",
|
|||
|
builder =>
|
|||
|
{
|
|||
|
builder.WithOrigins("https://freeso.org", "http://localhost:8080").AllowAnyMethod().AllowAnyHeader().AllowCredentials().WithExposedHeaders("content-disposition");
|
|||
|
});
|
|||
|
}).AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
|
|||
|
}
|
|||
|
|
|||
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|||
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime appLifetime)
|
|||
|
{
|
|||
|
if (env.IsDevelopment())
|
|||
|
{
|
|||
|
app.UseDeveloperExceptionPage();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
app.UseHsts();
|
|||
|
}
|
|||
|
app.UseCors();
|
|||
|
//app.UseHttpsRedirection();
|
|||
|
app.UseMvc();
|
|||
|
AppLifetime = appLifetime;
|
|||
|
}
|
|||
|
|
|||
|
public void Stop()
|
|||
|
{
|
|||
|
AppLifetime.StopApplication();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|