|
1 | | -using WebApplicationTest; |
| 1 | +using Scalar.AspNetCore; |
2 | 2 |
|
3 | | -var builder = WebApplication.CreateBuilder(args); |
| 3 | +namespace WebApplicationTest; |
4 | 4 |
|
5 | | -// Add services to the container. |
| 5 | +public static class Program |
| 6 | +{ |
6 | 7 |
|
7 | | -var services = builder.Services; |
8 | | -services.AddControllers(); |
9 | | -// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle |
10 | | -services.AddEndpointsApiExplorer(); |
11 | | -services.AddSwaggerGen(); |
| 8 | + #region Constants & Statics |
12 | 9 |
|
13 | | -services.Configure<SimpleOptions>(builder.Configuration.GetSection("SimpleOptions")); |
| 10 | + private static void Main(string[] args) |
| 11 | + { |
| 12 | + var builder = WebApplication.CreateBuilder(args); |
14 | 13 |
|
15 | | -services.Configure<ReadOnlyOptions>(builder.Configuration.GetSection("ReadOnlyOptions"), |
16 | | - options => options.BindNonPublicProperties = true); |
| 14 | + // Add services to the container. |
17 | 15 |
|
18 | | -services.Configure<PrivateOptions>(builder.Configuration.GetSection("PrivateOptions"), |
19 | | - options => options.BindNonPublicProperties = true); |
| 16 | + var services = builder.Services; |
| 17 | + _ = services.AddControllers(); |
| 18 | + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle |
| 19 | + _ = services.AddEndpointsApiExplorer(); |
| 20 | + _ = services.AddOpenApi(); |
20 | 21 |
|
21 | | -var app = builder.Build(); |
| 22 | + _ = services.AddHttpContextAccessor(); |
22 | 23 |
|
23 | | -// Configure the HTTP request pipeline. |
24 | | -if (app.Environment.IsDevelopment()) |
25 | | -{ |
26 | | - app.UseSwagger(); |
27 | | - app.UseSwaggerUI(); |
28 | | -} |
| 24 | + _ = services.Configure<SimpleOptions>(builder.Configuration.GetSection("SimpleOptions")); |
| 25 | + |
| 26 | + _ = services.Configure<ReadOnlyOptions>( |
| 27 | + builder.Configuration.GetSection("ReadOnlyOptions"), |
| 28 | + options => options.BindNonPublicProperties = true); |
| 29 | + |
| 30 | + _ = services.Configure<PrivateOptions>( |
| 31 | + builder.Configuration.GetSection("PrivateOptions"), |
| 32 | + options => options.BindNonPublicProperties = true); |
| 33 | + |
| 34 | + _ = builder.WebHost |
| 35 | + .ConfigureKestrel( |
| 36 | + serverOptions => |
| 37 | + { |
| 38 | + serverOptions.Limits.MaxResponseBufferSize = 10; // Disable response buffering limit |
| 39 | + }); |
29 | 40 |
|
30 | | -app.UseHttpsRedirection(); |
| 41 | + var app = builder.Build(); |
31 | 42 |
|
32 | | -app.UseAuthorization(); |
| 43 | + // Configure the HTTP request pipeline. |
| 44 | + if (app.Environment.IsDevelopment()) |
| 45 | + { |
| 46 | + _ = app.MapOpenApi(); |
| 47 | + _ = app.MapScalarApiReference(); |
| 48 | + } |
33 | 49 |
|
34 | | -app.MapControllers(); |
| 50 | + //_ = app.UseHttpsRedirection(); |
35 | 51 |
|
36 | | -app.Run(); |
| 52 | + _ = app.UseAuthorization(); |
| 53 | + |
| 54 | + _ = app.MapControllers(); |
| 55 | + |
| 56 | + app.Run(); |
| 57 | + } |
| 58 | + |
| 59 | + #endregion |
| 60 | + |
| 61 | +} |
0 commit comments