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

Loading…
Cancel
Save