55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using key4intranet.authentication;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using key4.AspNetCore.ExceptionHandler.Middleware;
|
|
using key4intranet.Api.Docs;
|
|
|
|
namespace key4intranet.Api {
|
|
public class Startup {
|
|
|
|
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.AddControllers();
|
|
|
|
services.AddAuthenticationServicesCollection();
|
|
|
|
services.AddScoped<IDocumentPathManager, DocumentPathManager>();
|
|
services.AddScoped<IDocumentManager, DocumentManager>();
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
|
|
if(env.IsDevelopment()) {
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
app.UseApiExceptionHandler();
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseCors(x => x
|
|
.AllowAnyOrigin()
|
|
.AllowAnyMethod()
|
|
.AllowAnyHeader());
|
|
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
app.UseEndpoints(endpoints => {
|
|
endpoints.MapControllers();
|
|
});
|
|
}
|
|
}
|
|
}
|