chore: 关闭生产Swagger并移除网关转发

This commit is contained in:
2025-12-04 22:42:46 +08:00
parent 64a5f61a6a
commit a42f470113
5 changed files with 62 additions and 69 deletions

View File

@@ -12,6 +12,7 @@ using TakeoutSaaS.Shared.Web.Swagger;
// 1. 创建构建器与日志模板
var builder = WebApplication.CreateBuilder(args);
const string logTemplate = "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} {Level:u3}] [TraceId:{TraceId}] [SpanId:{SpanId}] [Service:{Service}] {SourceContext} {Message:lj}{NewLine}{Exception}";
var isDevelopment = builder.Environment.IsDevelopment();
// 2. 注册雪花 ID 生成器与 Serilog
builder.Services.AddSingleton<IIdGenerator>(_ => new SnowflakeIdGenerator());
@@ -29,14 +30,17 @@ builder.Host.UseSerilog((_, _, configuration) =>
outputTemplate: logTemplate);
});
// 3. 注册通用 Web 能力 Swagger
// 3. 注册通用 Web 能力,开发环境启用 Swagger
builder.Services.AddSharedWebCore();
builder.Services.AddSharedSwagger(options =>
if (isDevelopment)
{
options.Title = "外卖SaaS - 用户端";
options.Description = "C 端用户 API 文档";
options.EnableAuthorization = true;
});
builder.Services.AddSharedSwagger(options =>
{
options.Title = "外卖SaaS - 用户端";
options.Description = "C 端用户 API 文档";
options.EnableAuthorization = true;
});
}
// 4. 注册多租户与健康检查
builder.Services.AddTenantResolution(builder.Configuration);
@@ -110,7 +114,10 @@ var app = builder.Build();
app.UseCors("UserApiCors");
app.UseTenantResolution();
app.UseSharedWebCore();
app.UseSharedSwagger();
if (app.Environment.IsDevelopment())
{
app.UseSharedSwagger();
}
app.MapHealthChecks("/healthz");
app.MapPrometheusScrapingEndpoint();