【新增】新增客户端IP限流模块。

This commit is contained in:
JianWeie
2022-05-20 14:48:06 +08:00
parent 05e2ff05bb
commit f973854d98
9 changed files with 228 additions and 1 deletions

View File

@@ -109,6 +109,8 @@ namespace CoreCms.Net.Web.WebApi
services.AddHttpClient();
services.AddSingleton<WeChat.Service.HttpClients.IWeChatApiHttpClientFactory, WeChat.Service.HttpClients.WeChatApiHttpClientFactory>();
//启用客户端IP限制速率
services.AddIpPolicyRateLimitSetup(Configuration);
//Swagger接口文档注入
services.AddClientSwaggerSetup();
@@ -178,6 +180,8 @@ namespace CoreCms.Net.Web.WebApi
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// 开启Ip限流
app.UseIpLimitMiddle();
// 记录请求与返回数据 (注意开启权限,不然本地无法写入)
app.UseRequestResponseLog();
// 用户访问记录(必须放到外层,不然如果遇到异常,会报错,因为不能返回流)(注意开启权限,不然本地无法写入)