转pdf minimal api 完成
continuous-integration/drone/push Build is passing

This commit is contained in:
hang
2024-10-19 18:22:58 +08:00
parent 41444bb292
commit 0ac17ac27f
7 changed files with 223 additions and 62 deletions
+20 -5
View File
@@ -144,14 +144,24 @@ builder.Services.AddMasaMinimalAPIs(options =>
options.RouteHandlerBuilder= t=> {
t.RequireAuthorization()
.AddEndpointFilter<LimitUserRequestAuthorizationEndpointFilter>()
.AddEndpointFilter<ModelValidationEndpointFilter>()
//.AddEndpointFilter<ModelValidationEndpointFilter>()
.AddEndpointFilter<UnifiedApiResultEndpointFilter>()
.WithGroupName("Institution");
.WithGroupName("Institution").DisableAntiforgery();
};
options.MapHttpMethodsForUnmatched = new string[] { "Post" };
options.DisableTrimMethodPrefix = true; //禁用去除方法前缀
options.DisableAutoMapRoute = false;//可通过配置true禁用全局自动路由映射或者删除此配置以启用全局自动路由映射
});
//// 添加反伪造服务
//builder.Services.AddAntiforgery(options =>
//{
// // 可选:设置自定义的头部名称以支持 AJAX 请求等
// options.HeaderName = "X-XSRF-TOKEN";
//});
//builder.Services.AddAntiforgery();
#endregion
var app = builder.Build();
@@ -160,7 +170,6 @@ var env = app.Environment;
#region
app.UseMiddleware<EncryptionRequestMiddleware>();
#region 400 -500
@@ -235,6 +244,13 @@ app.UseRouting();
app.UseCors(t => t.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
app.UseAuthentication();
app.UseAuthorization();
//Map MinimalAPI routes
app.MapMasaMinimalAPIs();
//// 这里添加反伪造中间件
//app.UseAntiforgery();
app.MapControllers();
app.MapHub<UploadHub>("/UploadHub");
@@ -244,8 +260,7 @@ app.MapHealthChecks("/health");
#endregion
//Map MinimalAPI routes
app.MapMasaMinimalAPIs();
// Serilog
SerilogExtension.AddSerilogSetup(enviromentName, app.Services);