2021-07-30 14:09:25 +08:00
|
|
|
|
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.TenpayV3.Sample_Net5
|
|
|
|
|
{
|
|
|
|
|
using SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings;
|
|
|
|
|
|
|
|
|
|
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();
|
2021-07-31 20:30:04 +08:00
|
|
|
|
services.Configure<Options.WxpayOptions>(Configuration.GetSection(nameof(Options.WxpayOptions)));
|
2021-07-30 14:09:25 +08:00
|
|
|
|
|
|
|
|
|
// ע<>빤<EFBFBD><EBB9A4> HTTP <20>ͻ<EFBFBD><CDBB><EFBFBD>
|
|
|
|
|
services.AddHttpClient();
|
|
|
|
|
services.AddSingleton<CertificateManager, InMemoryCertificateManager>();
|
|
|
|
|
services.AddSingleton<Services.HttpClients.IWechatTenpayHttpClientFactory, Services.HttpClients.Implements.WechatTenpayHttpClientFactory>();
|
2021-07-31 20:30:04 +08:00
|
|
|
|
|
|
|
|
|
// ע<><D7A2><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>
|
|
|
|
|
services.AddHostedService<Services.BackgroundServices.WxpayCertificateRefreshingBackgroundService>();
|
2021-07-30 14:09:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
|
{
|
|
|
|
|
endpoints.MapControllers();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|