-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
38 lines (25 loc) · 991 Bytes
/
Program.cs
File metadata and controls
38 lines (25 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using MyProject.Middlewares;
dotenv.net.DotEnv.Load();
var builder = WebApplication.CreateBuilder(args);
MyProject.Startup.DatabaseSetup.ConfigureServices(builder.Services, builder.Configuration);
MyProject.Startup.DependencyInjectionSetup.ConfigureServices(builder.Services, builder.Configuration);
MyProject.Startup.SwaggerSetup.ConfigureServices(builder.Services, builder.Configuration);
MyProject.Startup.CorsSetup.ConfigureServices(builder.Services);
builder.Services.AddControllers();
builder.Services.AddHttpContextAccessor();
var app = builder.Build();
app.UseCors("AllowAllOrigins");
app.UseMiddleware<ExceptionHandlingMiddleware>();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", app.Configuration.GetValue<string>("SWAGGER_API_NAME"));
});
}
app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.Run();