From 0b49fee10340ea40a6762da657239675d3db22f6 Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期四, 07 八月 2025 09:41:31 +0800 Subject: [PATCH] feat:权限和请求日志 --- FlexJobApi.Core/FlexJobApiCoreStartup.cs | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-) diff --git a/FlexJobApi.Core/FlexJobApiCoreStartup.cs b/FlexJobApi.Core/FlexJobApiCoreStartup.cs index 43e850c..a5a3aa0 100644 --- a/FlexJobApi.Core/FlexJobApiCoreStartup.cs +++ b/FlexJobApi.Core/FlexJobApiCoreStartup.cs @@ -1,4 +1,5 @@ -锘縰sing Furion; +锘縰sing Consul; +using Furion; using Furion.EventBus; using MediatR; using Microsoft.AspNetCore.Builder; @@ -19,16 +20,16 @@ { public void ConfigureServices(IServiceCollection services) { + services.AddHealthChecks(); + services.AddConsoleFormatter(options => { options.WithTraceId = true; - options.WithStackFrame = true; }); services.AddFileLogging(options => { options.WithTraceId = true; - options.WithStackFrame = true; options.FileNameRule = fileName => { return string.Format(fileName, DateTime.UtcNow); // 濡傛灉鏄湰鍦版椂闂翠娇鐢� DateTime.Now @@ -38,8 +39,13 @@ services.AddDatabaseLogging<DatabaseLoggingWriter>(options => { options.WithTraceId = true; - options.WithStackFrame = true; }); + + services.AddConfigurableOptions<AliyunOptions>(); + + services.AddHttpRemote(); + + services.AddComponent<ConsulServiceComponent>(); services.AddComponent<EventBusServiceComponent>(); @@ -48,6 +54,7 @@ services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(App.Assemblies.ToArray())); services.AddHostedService<XmlDocBuildHostedService>(); + services.AddHostedService<BuildDynamicControllersHostedService>(); services.AddJwt<JwtHandler>(enableGlobalAuthorize: true); @@ -62,14 +69,16 @@ services.AddControllers() .AddNewtonsoftJson(options => { - options.SerializerSettings.Converters.Add(new StringEnumConverter()); + //options.SerializerSettings.Converters.Add(new StringEnumConverter()); }) .AddFriendlyException() .AddDataValidation() .AddInjectWithUnifyResult<FriendlyResultProvider>(); + + services.AddMvcFilter<ResourceActionFilter>(); } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime) { // 瑙f瀽浜嬩欢鎬荤嚎鍙戝竷鏈嶅姟 var eventPublisher = app.ApplicationServices.GetRequiredService<IEventPublisher>(); @@ -87,7 +96,7 @@ app.UseUnifyResultStatusCodes(); - app.UseHttpsRedirection(); + //app.UseHttpsRedirection(); app.UseRouting(); @@ -103,7 +112,15 @@ app.UseEndpoints(endpoints => { endpoints.MapControllers(); + endpoints.MapHealthChecks("/healthz"); }); + + app.UseComponent<ConsulApplicationComponent>(env); + + //lifetime.ApplicationStarted.Register(async () => + //{ + // await ResourceUtils.BuildDynamicControllersAsync(); + //}); } } } -- Gitblit v1.9.1