mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-15 14:04:32 +08:00
55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
![]() |
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Microsoft.AspNetCore.Builder;
|
|||
|
using Microsoft.AspNetCore.Hosting;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using Microsoft.Extensions.Configuration;
|
|||
|
using Microsoft.Extensions.DependencyInjection;
|
|||
|
|
|||
|
namespace SKIT.FlurlHttpClient.Wechat.Api.Sample_Net5
|
|||
|
{
|
|||
|
public class Startup
|
|||
|
{
|
|||
|
public IConfiguration Configuration { get; }
|
|||
|
|
|||
|
public Startup(IConfiguration configuration)
|
|||
|
{
|
|||
|
Configuration = configuration;
|
|||
|
}
|
|||
|
|
|||
|
public void ConfigureServices(IServiceCollection services)
|
|||
|
{
|
|||
|
services.AddControllers();
|
|||
|
|
|||
|
// ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
services.AddOptions();
|
|||
|
services.Configure<Options.WechatOptions>(Configuration.GetSection(nameof(Options.WechatOptions)));
|
|||
|
|
|||
|
// ע<><D7A2><EFBFBD>ֲ<EFBFBD>ʽ<EFBFBD><CABD>
|
|||
|
services.AddSingleton<Services.DistributedLock.IDistributedLockFactory, Services.DistributedLock.Implements.DistributedLockFactory>();
|
|||
|
|
|||
|
// ע<><D7A2><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD>
|
|||
|
services.AddSingleton<Services.Repositories.IWechatAccessTokenEntityRepository, Services.Repositories.Implements.WechatAccessTokenEntityRepository>();
|
|||
|
|
|||
|
// ע<>빤<EFBFBD><EBB9A4> HTTP <20>ͻ<EFBFBD><CDBB><EFBFBD>
|
|||
|
services.AddHttpClient();
|
|||
|
services.AddSingleton<Services.HttpClients.IWechatApiHttpClientFactory, Services.HttpClients.Implements.WechatApiHttpClientFactory>();
|
|||
|
|
|||
|
// ע<><D7A2><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>
|
|||
|
services.AddHostedService<Services.BackgroundServices.WechatAccessTokenRefreshingBackgroundService>();
|
|||
|
}
|
|||
|
|
|||
|
public void Configure(IApplicationBuilder app)
|
|||
|
{
|
|||
|
app.UseRouting();
|
|||
|
|
|||
|
app.UseEndpoints(endpoints =>
|
|||
|
{
|
|||
|
endpoints.MapControllers();
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|