|
@@ -1,4 +1,4 @@ |
|
|
using AspectCore.Extensions.DependencyInjection; |
|
|
|
|
|
|
|
|
锘縰sing AspectCore.Extensions.DependencyInjection; |
|
|
using HealthMonitor.Common; |
|
|
using HealthMonitor.Common; |
|
|
using HealthMonitor.Common.helper; |
|
|
using HealthMonitor.Common.helper; |
|
|
using HealthMonitor.Core.Cache; |
|
|
using HealthMonitor.Core.Cache; |
|
@@ -39,7 +39,7 @@ namespace HealthMonitor.WebApi |
|
|
public static void Main(string[] args) |
|
|
public static void Main(string[] args) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
//选择配置文件appsetting.json |
|
|
|
|
|
|
|
|
//閫夋嫨閰嶇疆鏂囦欢appsetting.json |
|
|
var config = new ConfigurationBuilder() |
|
|
var config = new ConfigurationBuilder() |
|
|
.SetBasePath(Directory.GetCurrentDirectory()) |
|
|
.SetBasePath(Directory.GetCurrentDirectory()) |
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) |
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) |
|
@@ -56,7 +56,7 @@ namespace HealthMonitor.WebApi |
|
|
|
|
|
|
|
|
builder.Services.AddHttpClient(Consts.DEFAULT_HTTPCLIENT_NAME, c => |
|
|
builder.Services.AddHttpClient(Consts.DEFAULT_HTTPCLIENT_NAME, c => |
|
|
{ |
|
|
{ |
|
|
c.Timeout = TimeSpan.FromSeconds(10); //超时限制 |
|
|
|
|
|
|
|
|
c.Timeout = TimeSpan.FromSeconds(10); //瓒呮椂闄愬埗 |
|
|
c.DefaultRequestHeaders.Add("Accept", "application/json"); |
|
|
c.DefaultRequestHeaders.Add("Accept", "application/json"); |
|
|
//c.DefaultRequestHeaders.Connection.Add("keep-alive"); |
|
|
//c.DefaultRequestHeaders.Connection.Add("keep-alive"); |
|
|
}); |
|
|
}); |
|
@@ -72,7 +72,7 @@ namespace HealthMonitor.WebApi |
|
|
builder.Services.AddSwaggerGen(); |
|
|
builder.Services.AddSwaggerGen(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region scoped MySQL 数据库 |
|
|
|
|
|
|
|
|
#region scoped MySQL 鏁版嵁搴� |
|
|
builder.Services // gps_card |
|
|
builder.Services // gps_card |
|
|
.AddDbContextPool<GpsCardContext>((sp, options) => |
|
|
.AddDbContextPool<GpsCardContext>((sp, options) => |
|
|
{ |
|
|
{ |
|
@@ -161,7 +161,7 @@ namespace HealthMonitor.WebApi |
|
|
.AddSingleton<IHealthMonitorOperatorManager, HealthMonitorOperatorRedisManager>(); |
|
|
.AddSingleton<IHealthMonitorOperatorManager, HealthMonitorOperatorRedisManager>(); |
|
|
//builder.Services.AddSingleton<IHealthMonitorOperatorManager, HealthMonitorOperatorRedisManager>(); |
|
|
//builder.Services.AddSingleton<IHealthMonitorOperatorManager, HealthMonitorOperatorRedisManager>(); |
|
|
|
|
|
|
|
|
//用AspectCore替换默认的IOC容器 |
|
|
|
|
|
|
|
|
//鐢ˋspectCore鏇挎崲榛樿�鐨処OC瀹瑰櫒 |
|
|
builder.Host.UseServiceProviderFactory(new DynamicProxyServiceProviderFactory()); |
|
|
builder.Host.UseServiceProviderFactory(new DynamicProxyServiceProviderFactory()); |
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
@@ -203,8 +203,8 @@ namespace HealthMonitor.WebApi |
|
|
// Register the Swagger generator, defining 1 or more Swagger documents |
|
|
// Register the Swagger generator, defining 1 or more Swagger documents |
|
|
builder.Services.AddSwaggerGen(c => |
|
|
builder.Services.AddSwaggerGen(c => |
|
|
{ |
|
|
{ |
|
|
//c.SwaggerDoc(AppConsts.SWAGGER_DOC_GpsCard, new OpenApiInfo { Title = "GpsCard模块", Version = "v1", Description = "gps_card数据库服务" }); //分组显示 |
|
|
|
|
|
c.SwaggerDoc(AppConsts.SWAGGER_DOC_HealthMonitor, new OpenApiInfo { Title = "HealthMonitor模块", Version = "v1", Description = "health_monitor数据库服务" }); //分组显示 |
|
|
|
|
|
|
|
|
//c.SwaggerDoc(AppConsts.SWAGGER_DOC_GpsCard, new OpenApiInfo { Title = "GpsCard妯″潡", Version = "v1", Description = "gps_card鏁版嵁搴撴湇鍔�" }); //鍒嗙粍鏄剧ず |
|
|
|
|
|
c.SwaggerDoc(AppConsts.SWAGGER_DOC_HealthMonitor, new OpenApiInfo { Title = "HealthMonitor妯″潡", Version = "v1", Description = "health_monitor鏁版嵁搴撴湇鍔�" }); //鍒嗙粍鏄剧ず |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c.DocumentFilter<EnumDocumentFilter>(); |
|
|
c.DocumentFilter<EnumDocumentFilter>(); |
|
@@ -254,8 +254,8 @@ namespace HealthMonitor.WebApi |
|
|
app.UseSwaggerUI(c => |
|
|
app.UseSwaggerUI(c => |
|
|
{ |
|
|
{ |
|
|
string sub = string.IsNullOrEmpty(prefix) ? "" : $"/{prefix}"; |
|
|
string sub = string.IsNullOrEmpty(prefix) ? "" : $"/{prefix}"; |
|
|
//c.SwaggerEndpoint($"{sub}/{AppConsts.SWAGGER_DOC_GpsCard}/api-docs/", "GpsCard模块"); //分组显示 |
|
|
|
|
|
c.SwaggerEndpoint($"{sub}/{AppConsts.SWAGGER_DOC_HealthMonitor}/api-docs/", "HealthMonitor模块"); //分组显示 |
|
|
|
|
|
|
|
|
//c.SwaggerEndpoint($"{sub}/{AppConsts.SWAGGER_DOC_GpsCard}/api-docs/", "GpsCard妯″潡"); //鍒嗙粍鏄剧ず |
|
|
|
|
|
c.SwaggerEndpoint($"{sub}/{AppConsts.SWAGGER_DOC_HealthMonitor}/api-docs/", "HealthMonitor妯″潡"); //鍒嗙粍鏄剧ず |
|
|
c.RoutePrefix = string.Empty; |
|
|
c.RoutePrefix = string.Empty; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|