Skip to content

Asp .Net Core项目中,以服务基地址为标识的HttpClient池管理模块

License

Notifications You must be signed in to change notification settings

kinglionsoft/KingLion.WebUtils.HttpClientPool

Repository files navigation

KingLion.WebUtils.HttpClientPool

Asp .Net Core项目中,以服务基地址为标识的HttpClient池管理模块。

使用“池”来管理HttClient的原因,详见https://news.cnblogs.com/n/553217/http://www.cnblogs.com/dudu/p/csharp-httpclient-attention.html

安装

NuGet:

Install-Package KingLion.WebUtils.HttpClientPool

用法

  1. 启用Job Manager

    • Startup-> ConfigureServices:
    services.AddMemoryCache();
    services.AddHttpClientPool();
    • Startup-> Configure:
    app.UseHttpClientPool();
  2. 添加作业

    • 注入IHttpClientPool;
    • 添加作业:
    var client=_httpClientPool.GetClient("http://xxx.com",TimeSpan.FromHours(2));

About

Asp .Net Core项目中,以服务基地址为标识的HttpClient池管理模块

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages