|
19 | 19 |
|
20 | 20 | // Add services to the container. |
21 | 21 |
|
22 | | -builder.Services.AddControllers(); |
| 22 | +builder.Services.AddControllers().AddNewtonsoftJson(options => |
| 23 | +{ |
| 24 | + options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; |
| 25 | + options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; |
| 26 | +}); |
23 | 27 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle |
24 | 28 | builder.Services.AddEndpointsApiExplorer(); |
25 | 29 |
|
|
42 | 46 | .AllowAnyHeader() |
43 | 47 | .AllowAnyMethod().AllowCredentials() |
44 | 48 | )); |
45 | | -builder.Services.AddControllers() |
46 | | - .AddNewtonsoftJson(options => |
47 | | - { |
48 | | - options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; |
49 | | - options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; |
50 | | - }); ; |
| 49 | + |
51 | 50 | builder.Services.AddSwaggerGen(c => |
52 | 51 | { |
53 | 52 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "APIJSON.NET", Version = "v1" }); |
54 | 53 | }); |
55 | 54 | builder.Services.AddSingleton<DbContext>(); |
56 | | -builder.Services.AddSingleton<SelectTable>(); |
| 55 | + |
57 | 56 | builder.Services.AddSingleton<TokenAuthConfiguration>(); |
58 | 57 | builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); |
59 | 58 | builder.Services.AddTransient<IIdentityService, IdentityService>(); |
60 | 59 | builder.Services.AddTransient<ITableMapper, TableMapper>(); |
61 | | - |
| 60 | + |
62 | 61 |
|
63 | 62 | var app = builder.Build(); |
64 | 63 |
|
|
74 | 73 | } |
75 | 74 |
|
76 | 75 | app.UseHttpsRedirection(); |
| 76 | +app.UseDefaultFiles(); |
77 | 77 | app.UseStaticFiles(); |
78 | 78 | app.UseAuthorization(); |
79 | 79 | app.UseCors(_defaultCorsPolicyName); |
|
0 commit comments