Browse Source

添加2。0系统的通信主机,添加http日志记录

develop-lawyerExampaper
胡超1 2 years ago
parent
commit
5110c390d8
  1. 18
      24Hour/Program.cs

18
24Hour/Program.cs

@ -20,6 +20,7 @@ using AutoMapper;
using System.Reflection; using System.Reflection;
using Elight.Entity; using Elight.Entity;
using _24Hour; using _24Hour;
using Microsoft.Extensions.DependencyInjection;
#region builder #region builder
@ -177,7 +178,10 @@ builder.Services.AddHttpClient<WechatMessagerClient>(opt =>
{ {
opt.BaseAddress = new Uri("https://api.weixin.qq.com/sns"); opt.BaseAddress = new Uri("https://api.weixin.qq.com/sns");
}); });
builder.Services.AddHttpClient<CaseServiceTwentyClient>(opt =>
{
opt.BaseAddress = new Uri(Configuration.GetSection("CaseTwenty:SysAddress").Value);
});
//builder.Services.AddAuthorization(); //builder.Services.AddAuthorization();
builder.Services.AddHttpContextAccessor(); builder.Services.AddHttpContextAccessor();
builder.Services.AddScoped<WebSocketController>(); builder.Services.AddScoped<WebSocketController>();
@ -195,6 +199,11 @@ builder.Services.AddScoped<SqlSugarClient>(sp =>
}); });
return db; return db;
}); });
//添加httpclient 日志记录
builder.Services.AddHttpLogging(logging =>
{
logging.LoggingFields = Microsoft.AspNetCore.HttpLogging.HttpLoggingFields.All;
});
#region 定时任务 #region 定时任务
// 配置Quartz.NET调度器 // 配置Quartz.NET调度器
@ -244,6 +253,9 @@ app.UseWebSockets(new WebSocketOptions
app.UseStaticFiles(); app.UseStaticFiles();
//app.UseHttpsRedirection(); //app.UseHttpsRedirection();
//路由 //路由
//使用httpclient日志记录 必须在UseStaticFiles下面
app.UseHttpLogging();
app.UseRouting(); app.UseRouting();
app.UseAuthentication(); // 启用身份验证中间件 app.UseAuthentication(); // 启用身份验证中间件
app.UseAuthorization(); // 启用授权中间件 app.UseAuthorization(); // 启用授权中间件
@ -257,8 +269,8 @@ app.UseSwagger();//
app.UseSwaggerUI(c => app.UseSwaggerUI(c =>
{ {
c.SwaggerEndpoint("/swagger/v1/swagger.json", "24小时一体机 API V1"); c.SwaggerEndpoint("/swagger/v1/swagger.json", "24小时一体机 API V1");
c.RoutePrefix = string.Empty; c.RoutePrefix = string.Empty;
}); });
#endregion #endregion

Loading…
Cancel
Save