|
1 | 1 | using OpenReservation.Notification; |
| 2 | +using Scalar.AspNetCore; |
2 | 3 | using SendGrid; |
3 | 4 | using WeihanLi.Web.Authentication; |
4 | 5 | using WeihanLi.Web.Extensions; |
5 | 6 |
|
6 | 7 | var builder = WebApplication.CreateSlimBuilder(args); |
7 | 8 |
|
8 | 9 | // Add services to the container. |
9 | | -// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle |
10 | | -builder.Services.AddEndpointsApiExplorer(); |
11 | | -builder.Services.AddSwaggerGen(); |
| 10 | +// OpenApi https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/overview |
| 11 | +builder.Services.AddOpenApi(); |
12 | 12 |
|
13 | 13 | builder.Services.AddMemoryCache(); |
14 | 14 |
|
|
26 | 26 | var app = builder.Build(); |
27 | 27 |
|
28 | 28 | // Configure the HTTP request pipeline. |
29 | | -if (app.Environment.IsDevelopment()) |
30 | | -{ |
31 | | - app.UseSwagger(); |
32 | | - app.UseSwaggerUI(); |
33 | | -} |
| 29 | +app.MapOpenApi().ShortCircuit().DisableHttpMetrics(); |
| 30 | +app.MapScalarApiReference().ShortCircuit().DisableHttpMetrics(); |
34 | 31 |
|
35 | 32 | app.UseAuthentication() |
36 | 33 | .UseAuthorization(); |
37 | 34 |
|
38 | 35 | var healthChecks = app.MapGroup("/api/health"); |
39 | | -healthChecks.MapGet("/live", () => Results.Ok()).ShortCircuit(); |
40 | | -healthChecks.MapGet("/ready", () => Results.Ok()).ShortCircuit(); |
| 36 | +healthChecks.MapGet("/live", () => Results.Ok()).ShortCircuit().DisableHttpMetrics(); |
| 37 | +healthChecks.MapGet("/ready", () => Results.Ok()).ShortCircuit().DisableHttpMetrics(); |
41 | 38 |
|
42 | | -app.MapRuntimeInfo().ShortCircuit(); |
| 39 | +app.MapRuntimeInfo().ShortCircuit().DisableHttpMetrics(); |
43 | 40 | app.MapPost("/api/notification/{notificationType}", async (NotificationType notificationType, NotificationRequest request, HttpContext context) => |
44 | 41 | { |
45 | 42 | var notification = context.RequestServices.GetRequiredKeyedService<INotification>(notificationType); |
|
0 commit comments