权限code过滤器

This commit is contained in:
陈淳
2022-09-27 16:22:34 +08:00
parent 26e08774b0
commit 6ce05984d5
9 changed files with 44 additions and 27 deletions

View File

@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -15,10 +16,11 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
public class ErrorHandExtension
{
private readonly RequestDelegate next;
public ErrorHandExtension(RequestDelegate next)
private ILogger<ErrorHandExtension> _logger;
public ErrorHandExtension(RequestDelegate next,ILogger<ErrorHandExtension> logger)
{
this.next = next;
_logger = logger;
}
public async Task Invoke(HttpContext context)
@@ -34,6 +36,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
{
statusCode = 200;
}
_logger.LogError($"中间件抓取错误\r\n错误信息{ex.Message}\r\n堆栈信息“{ex.StackTrace}");
await HandleExceptionAsync(context, statusCode, ex.Message);
}
finally