32
This commit is contained in:
parent
4646a67e15
commit
8b17e1b84d
|
|
@ -1,5 +1,6 @@
|
|||
using Autofac;
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
|
||||
using HoneyBox.Api.Filters;
|
||||
using HoneyBox.Core.Mappings;
|
||||
using HoneyBox.Infrastructure.Cache;
|
||||
|
|
@ -7,11 +8,15 @@ using HoneyBox.Infrastructure.Modules;
|
|||
using HoneyBox.Model.Data;
|
||||
using HoneyBox.Model.Models.Auth;
|
||||
using HoneyBox.Model.Models.Payment;
|
||||
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
using Scalar.AspNetCore;
|
||||
|
||||
using Serilog;
|
||||
|
||||
using System.Text;
|
||||
|
||||
// 配置 Serilog
|
||||
|
|
@ -143,20 +148,20 @@ try
|
|||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
// 使用 OpenAPI 和 Scalar UI
|
||||
app.MapOpenApi();
|
||||
app.MapScalarApiReference(options =>
|
||||
{
|
||||
options.WithTitle("HoneyBox API");
|
||||
options.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient);
|
||||
});
|
||||
|
||||
// 添加根路径重定向到 Scalar 文档
|
||||
app.MapGet("/", () => Results.Redirect("/scalar/v1"));
|
||||
// 配置 HTTP 请求管道
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
// 使用 OpenAPI 和 Scalar UI
|
||||
app.MapOpenApi();
|
||||
app.MapScalarApiReference(options =>
|
||||
{
|
||||
options.WithTitle("HoneyBox API");
|
||||
options.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient);
|
||||
});
|
||||
|
||||
// 添加根路径重定向到 Scalar 文档
|
||||
app.MapGet("/", () => Results.Redirect("/scalar/v1"));
|
||||
|
||||
// 仅开发环境启用 CORS,生产环境由 Nginx 配置
|
||||
app.UseCors("Development");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user