-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
54 lines (40 loc) · 1.22 KB
/
Program.cs
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using System.Text;
using TweetAPI.Config;
using TweetAPI.Data;
using TweetAPI.Installers;
using TweetAPI.Options;
WebApplicationBuilder? builder = WebApplication.CreateBuilder(args);
builder.Services.ServicesInit(builder.Configuration);
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseMigrationsEndPoint();
var swagConfig = new SwaggerOptions();
builder.Configuration.GetSection(nameof(SwaggerOptions)).Bind(swagConfig);
app.UseSwagger(config =>
{
config.RouteTemplate = swagConfig.JsonRoute;
});
app.UseSwaggerUI(config =>
{
config.SwaggerEndpoint(swagConfig.UIEndpoint, swagConfig.Description);
});
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthentication();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.MapRazorPages();
using (var scope = app.Services.CreateScope())
{
var services = scope.ServiceProvider;
var context = services.GetRequiredService<DataContext>();
//context.Database.Migrate();
}
app.Run();