From c971161d314d6ba9fec1b30f6dc89a64d85fe335 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 3 Jan 2024 11:19:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9utf-8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/Startup.cs | 66 +++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/IRaCIS.Core.API/Startup.cs b/IRaCIS.Core.API/Startup.cs index f7ef89e47..9d7a01577 100644 --- a/IRaCIS.Core.API/Startup.cs +++ b/IRaCIS.Core.API/Startup.cs @@ -1,4 +1,4 @@ -using Autofac; +using Autofac; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http.Features; @@ -53,7 +53,7 @@ namespace IRaCIS.Core.API containerBuilder.RegisterModule(); #region Test - //containerBuilder.RegisterType().PropertiesAutowired().InstancePerLifetimeScope();//עִ + //containerBuilder.RegisterType().PropertiesAutowired().InstancePerLifetimeScope();//注册仓储 //var container = containerBuilder.Build(); @@ -75,12 +75,12 @@ namespace IRaCIS.Core.API // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - // + //健康检查 services.AddHealthChecks(); - //ػ + //本地化 services.AddJsonLocalization(options => options.ResourcesPath = "Resources"); - // 쳣ͳһ֤JsonлáַͳһTrim() + // 异常、参数统一验证过滤器、Json序列化配置、字符串参数绑型统一Trim() services.AddControllers(options => { //options.Filters.Add(); @@ -95,7 +95,7 @@ namespace IRaCIS.Core.API }) - .AddNewtonsoftJsonSetup(); // NewtonsoftJson л + .AddNewtonsoftJsonSetup(); // NewtonsoftJson 序列化 处理 services.AddOptions().Configure(_configuration.GetSection("SystemEmailSendConfig")); services.AddOptions().Configure(_configuration.GetSection("BasicSystemConfig")); @@ -103,62 +103,62 @@ namespace IRaCIS.Core.API services.AddOptions().Configure(_configuration.GetSection("ObjectStoreService")); - //̬WebApi + UnifiedApiResultFilter ʡ + //动态WebApi + UnifiedApiResultFilter 省掉控制器代码 services.AddDynamicWebApiSetup(); //AutoMapper services.AddAutoMapperSetup(); //EF ORM QueryWithNoLock services.AddEFSetup(_configuration); - //Http Ӧѹ + //Http 响应压缩 services.AddResponseCompressionSetup(); - //Swagger Api ĵ + //Swagger Api 文档 services.AddSwaggerSetup(); - //JWT Token ֤ + //JWT Token 验证 services.AddJWTAuthSetup(_configuration); - // MediatR Ϣ ¼ ӳ עhandlerӦϵ + // MediatR 进程内消息 事件解耦 从程序集中 注册命令和handler对应关系 services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining()); - // EasyCaching + // EasyCaching 缓存 services.AddEasyCachingSetup(_configuration); //services.AddDistributedMemoryCache(); - // hangfire ʱ н棬Ѻ~ + // hangfire 定时任务框架 有界面,更友好~ services.AddhangfireSetup(_configuration); - // QuartZ ʱ ʹhangfire ʱãҪԴ򿪣Ѿ + // QuartZ 定时任务框架 使用了hangfire 暂时不用,后续需要可以打开,已经配好 services.AddQuartZSetup(_configuration); - // ϴļ + // 保护上传文件 //services.AddStaticFileAuthorizationSetup(); - ////HttpReports ʱ + ////HttpReports 暂时废弃 //services.AddHttpReports().AddHttpTransport(); - //Serilog ־ӻ LogDashboard־ + //Serilog 日志可视化 LogDashboard日志 services.AddLogDashboardSetup(); - //ϴ + //上传限制 配置 services.Configure(options => { options.MultipartBodyLengthLimit = int.MaxValue; options.ValueCountLimit = int.MaxValue; options.ValueLengthLimit = int.MaxValue; }); - //IP ð ߺ + //IP 限流 可设置白名单 或者黑名单 //services.AddIpPolicyRateLimitSetup(_configuration); - // û Ȩ + // 用户类型 策略授权 //services.AddAuthorizationPolicySetup(_configuration); services.AddJsonConfigSetup(_configuration); - //תͷ ȡʵIP + //转发头设置 获取真实IP services.Configure(options => { options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; }); - //DicomӰȾͼƬ ƽ̨ + //Dicom影像渲染图片 跨平台 services.AddDicomSetup(); - // ʵʱӦ + // 实时应用 services.AddSignalR(); @@ -175,17 +175,17 @@ namespace IRaCIS.Core.API { //app.UsePathBase(PathString.FromUriComponent("/api")); - //ػ + //本地化 app.UseLocalization(); app.UseForwardedHeaders(); - //Ӧѹ + //响应压缩 app.UseResponseCompression(); //app.UseCors(t => t.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); - //Ҫ token ʵľ̬ļ wwwroot css, JavaScript, and images don't require authentication. + //不需要 token 访问的静态文件 wwwroot css, JavaScript, and images don't require authentication. app.UseStaticFiles(); @@ -195,10 +195,10 @@ namespace IRaCIS.Core.API //hangfire app.UseHangfireConfig(env); - ////ʱ + ////暂时废弃 //app.UseHttpReports(); - //// м + ////限流 中间件 //app.UseIpRateLimiting(); @@ -211,18 +211,18 @@ namespace IRaCIS.Core.API { //app.UseHsts(); } - Console.WriteLine("ǰ " + env.EnvironmentName); + Console.WriteLine("当前环境: " + env.EnvironmentName); //app.UseMiddleware(); - // 쳣 404 + // 特殊异常处理 比如 404 app.UseStatusCodePagesWithReExecute("/Error/{0}"); SwaggerSetup.Configure(app, env); - ////serilog ¼ûϢ + ////serilog 记录请求的用户信息 app.UseSerilogConfig(env); app.UseRouting(); @@ -237,7 +237,7 @@ namespace IRaCIS.Core.API //app.UseJwtBearerQueryString(); app.UseAuthorization(); - ////ļŷ Token + ////文件伺服 必须带Token 访问 ////app.UseIRacisHostStaticFileStore(env); app.UseEndpoints(endpoints => @@ -253,7 +253,7 @@ namespace IRaCIS.Core.API var hangfireJobService = app.ApplicationServices.GetRequiredService(); await hangfireJobService.InitHangfireJobTaskAsync(); - //еʱÿ + //有的时候每调用 //HangfireJobHelper.NotImmediatelyOnceOnlyJob(t => t.InitHangfireJobTaskAsync(),TimeSpan.FromSeconds(1));