Skip to content

Commit

Permalink
Merge pull request #55 from bing-framework/dev_3.1
Browse files Browse the repository at this point in the history
publish: 2.2.0
  • Loading branch information
jianxuanbing authored Feb 8, 2022
2 parents 7bf7a7c + 1d73572 commit 811c092
Show file tree
Hide file tree
Showing 270 changed files with 8,501 additions and 1,083 deletions.
106 changes: 100 additions & 6 deletions Bing.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "01-Biz", "01-Biz", "{16E325
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "02-Serialization", "02-Serialization", "{6883A733-F108-4018-B38A-322804F78DAE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DDD", "DDD", "{AED4D92B-5196-47E9-BD2C-84D4077F5A70}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "03-DDD", "03-DDD", "{AED4D92B-5196-47E9-BD2C-84D4077F5A70}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ORM", "ORM", "{93A682FB-8EA0-4F10-AC03-CD688025E624}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "04-ORM", "04-ORM", "{93A682FB-8EA0-4F10-AC03-CD688025E624}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Logs", "Logs", "{33F6CAB3-FD8A-4B91-9B94-A1E2DBC2759B}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "02-Logs", "02-Logs", "{33F6CAB3-FD8A-4B91-9B94-A1E2DBC2759B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{C6B2743E-B7EE-418C-9F9B-79976B71C46B}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "00-Core", "00-Core", "{C6B2743E-B7EE-418C-9F9B-79976B71C46B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Web", "Web", "{052D4342-8B65-4836-A9B6-681A7812760E}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "05-Web", "05-Web", "{052D4342-8B65-4836-A9B6-681A7812760E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Caching", "Caching", "{9559AE76-7924-4647-8619-35EE39569D6C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Emailing", "Emailing", "{B8142AAE-3792-44C0-9197-0F14A9749E33}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Events", "Events", "{B5285F1C-479F-43F5-B3DE-3E930516AF6D}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "06-Events", "06-Events", "{B5285F1C-479F-43F5-B3DE-3E930516AF6D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Abstractions", "framework\src\Bing.Abstractions\Bing.Abstractions.csproj", "{040209E9-B364-47E0-8922-89210ACCFB24}"
EndProject
Expand Down Expand Up @@ -214,6 +214,34 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Locks.CSRedis", "frame
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Logs.NLog", "framework\src\Bing.Logs.NLog\Bing.Logs.NLog.csproj", "{A073A8B8-C116-4D8E-A519-DF950F68D2DA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Validation", "framework\src\Bing.Validation\Bing.Validation.csproj", "{D1131EC5-CF40-418F-8E8C-858AADDBCC7F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.AspNetCore.Authentication.JwtBearer", "framework\src\Bing.AspNetCore.Authentication.JwtBearer\Bing.AspNetCore.Authentication.JwtBearer.csproj", "{7F4DAD82-FB09-445C-8EA2-0F1C50FBBA28}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TextTemplating", "TextTemplating", "{09A94120-CE45-402F-B45A-21DF04F0C226}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.TextTemplating", "framework\src\Bing.TextTemplating\Bing.TextTemplating.csproj", "{E06DC786-72AB-417B-ACDB-AF00688544EA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.TextTemplating.Scriban", "framework\src\Bing.TextTemplating.Scriban\Bing.TextTemplating.Scriban.csproj", "{65B439C9-4B54-4DB8-86B3-9EBE8E62DF83}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Test.Shared", "framework\tests\Bing.Test.Shared\Bing.Test.Shared.csproj", "{D6C96AE5-8756-4278-A331-43073E08C3ED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Ddd.Domain.Tests", "framework\tests\Bing.Ddd.Domain.Tests\Bing.Ddd.Domain.Tests.csproj", "{8B581529-D7D2-4DCF-824A-2AAFB58F8C94}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.EventBus", "framework\src\Bing.EventBus\Bing.EventBus.csproj", "{5E8AD211-7AEF-4D9D-AFA8-C85B6F3D7C6A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.EventBus.Tests", "framework\tests\Bing.EventBus.Tests\Bing.EventBus.Tests.csproj", "{0A5D1639-8EEE-4BC9-94A5-04F354FEFBFD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Logging", "framework\src\Bing.Logging\Bing.Logging.csproj", "{427DC057-A61A-4D4A-9B20-30F11367AFC8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Logging.Serilog", "framework\src\Bing.Logging.Serilog\Bing.Logging.Serilog.csproj", "{C935C3C7-0CEB-4583-9039-114631C38989}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Logging.Sinks.Exceptionless", "framework\src\Bing.Logging.Sinks.Exceptionless\Bing.Logging.Sinks.Exceptionless.csproj", "{C7E17279-AAEB-4A58-BBBB-AF443F924D9E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Logging.Tests", "framework\tests\Bing.Logging.Tests\Bing.Logging.Tests.csproj", "{73871EF9-9CF6-479F-BC1C-AD443CE037AE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bing.Logging.Serilog.Tests", "framework\tests\Bing.Logging.Serilog.Tests\Bing.Logging.Serilog.Tests.csproj", "{857BF156-74BE-4D71-8814-A1ECAA958C2D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -472,6 +500,58 @@ Global
{A073A8B8-C116-4D8E-A519-DF950F68D2DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A073A8B8-C116-4D8E-A519-DF950F68D2DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A073A8B8-C116-4D8E-A519-DF950F68D2DA}.Release|Any CPU.Build.0 = Release|Any CPU
{D1131EC5-CF40-418F-8E8C-858AADDBCC7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1131EC5-CF40-418F-8E8C-858AADDBCC7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1131EC5-CF40-418F-8E8C-858AADDBCC7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1131EC5-CF40-418F-8E8C-858AADDBCC7F}.Release|Any CPU.Build.0 = Release|Any CPU
{7F4DAD82-FB09-445C-8EA2-0F1C50FBBA28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F4DAD82-FB09-445C-8EA2-0F1C50FBBA28}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F4DAD82-FB09-445C-8EA2-0F1C50FBBA28}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F4DAD82-FB09-445C-8EA2-0F1C50FBBA28}.Release|Any CPU.Build.0 = Release|Any CPU
{E06DC786-72AB-417B-ACDB-AF00688544EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E06DC786-72AB-417B-ACDB-AF00688544EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E06DC786-72AB-417B-ACDB-AF00688544EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E06DC786-72AB-417B-ACDB-AF00688544EA}.Release|Any CPU.Build.0 = Release|Any CPU
{65B439C9-4B54-4DB8-86B3-9EBE8E62DF83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65B439C9-4B54-4DB8-86B3-9EBE8E62DF83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65B439C9-4B54-4DB8-86B3-9EBE8E62DF83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65B439C9-4B54-4DB8-86B3-9EBE8E62DF83}.Release|Any CPU.Build.0 = Release|Any CPU
{D6C96AE5-8756-4278-A331-43073E08C3ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6C96AE5-8756-4278-A331-43073E08C3ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6C96AE5-8756-4278-A331-43073E08C3ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6C96AE5-8756-4278-A331-43073E08C3ED}.Release|Any CPU.Build.0 = Release|Any CPU
{8B581529-D7D2-4DCF-824A-2AAFB58F8C94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B581529-D7D2-4DCF-824A-2AAFB58F8C94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B581529-D7D2-4DCF-824A-2AAFB58F8C94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B581529-D7D2-4DCF-824A-2AAFB58F8C94}.Release|Any CPU.Build.0 = Release|Any CPU
{5E8AD211-7AEF-4D9D-AFA8-C85B6F3D7C6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E8AD211-7AEF-4D9D-AFA8-C85B6F3D7C6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E8AD211-7AEF-4D9D-AFA8-C85B6F3D7C6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E8AD211-7AEF-4D9D-AFA8-C85B6F3D7C6A}.Release|Any CPU.Build.0 = Release|Any CPU
{0A5D1639-8EEE-4BC9-94A5-04F354FEFBFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A5D1639-8EEE-4BC9-94A5-04F354FEFBFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A5D1639-8EEE-4BC9-94A5-04F354FEFBFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A5D1639-8EEE-4BC9-94A5-04F354FEFBFD}.Release|Any CPU.Build.0 = Release|Any CPU
{427DC057-A61A-4D4A-9B20-30F11367AFC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{427DC057-A61A-4D4A-9B20-30F11367AFC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{427DC057-A61A-4D4A-9B20-30F11367AFC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{427DC057-A61A-4D4A-9B20-30F11367AFC8}.Release|Any CPU.Build.0 = Release|Any CPU
{C935C3C7-0CEB-4583-9039-114631C38989}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C935C3C7-0CEB-4583-9039-114631C38989}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C935C3C7-0CEB-4583-9039-114631C38989}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C935C3C7-0CEB-4583-9039-114631C38989}.Release|Any CPU.Build.0 = Release|Any CPU
{C7E17279-AAEB-4A58-BBBB-AF443F924D9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7E17279-AAEB-4A58-BBBB-AF443F924D9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7E17279-AAEB-4A58-BBBB-AF443F924D9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7E17279-AAEB-4A58-BBBB-AF443F924D9E}.Release|Any CPU.Build.0 = Release|Any CPU
{73871EF9-9CF6-479F-BC1C-AD443CE037AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73871EF9-9CF6-479F-BC1C-AD443CE037AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73871EF9-9CF6-479F-BC1C-AD443CE037AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73871EF9-9CF6-479F-BC1C-AD443CE037AE}.Release|Any CPU.Build.0 = Release|Any CPU
{857BF156-74BE-4D71-8814-A1ECAA958C2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{857BF156-74BE-4D71-8814-A1ECAA958C2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{857BF156-74BE-4D71-8814-A1ECAA958C2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{857BF156-74BE-4D71-8814-A1ECAA958C2D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -565,6 +645,20 @@ Global
{F8BFB799-8ECB-49F6-AAA4-5B07F64DB3D9} = {3030FE3D-DB8F-403D-A181-8152670827AB}
{2C0C2E7B-25AC-4B48-AF62-59E3C5808AEC} = {F8BFB799-8ECB-49F6-AAA4-5B07F64DB3D9}
{A073A8B8-C116-4D8E-A519-DF950F68D2DA} = {33F6CAB3-FD8A-4B91-9B94-A1E2DBC2759B}
{D1131EC5-CF40-418F-8E8C-858AADDBCC7F} = {C6B2743E-B7EE-418C-9F9B-79976B71C46B}
{7F4DAD82-FB09-445C-8EA2-0F1C50FBBA28} = {052D4342-8B65-4836-A9B6-681A7812760E}
{09A94120-CE45-402F-B45A-21DF04F0C226} = {3030FE3D-DB8F-403D-A181-8152670827AB}
{E06DC786-72AB-417B-ACDB-AF00688544EA} = {09A94120-CE45-402F-B45A-21DF04F0C226}
{65B439C9-4B54-4DB8-86B3-9EBE8E62DF83} = {09A94120-CE45-402F-B45A-21DF04F0C226}
{D6C96AE5-8756-4278-A331-43073E08C3ED} = {5C7976B4-C243-41B9-8303-8E8FAE099D31}
{8B581529-D7D2-4DCF-824A-2AAFB58F8C94} = {5C7976B4-C243-41B9-8303-8E8FAE099D31}
{5E8AD211-7AEF-4D9D-AFA8-C85B6F3D7C6A} = {B5285F1C-479F-43F5-B3DE-3E930516AF6D}
{0A5D1639-8EEE-4BC9-94A5-04F354FEFBFD} = {5C7976B4-C243-41B9-8303-8E8FAE099D31}
{427DC057-A61A-4D4A-9B20-30F11367AFC8} = {33F6CAB3-FD8A-4B91-9B94-A1E2DBC2759B}
{C935C3C7-0CEB-4583-9039-114631C38989} = {33F6CAB3-FD8A-4B91-9B94-A1E2DBC2759B}
{C7E17279-AAEB-4A58-BBBB-AF443F924D9E} = {33F6CAB3-FD8A-4B91-9B94-A1E2DBC2759B}
{73871EF9-9CF6-479F-BC1C-AD443CE037AE} = {5C7976B4-C243-41B9-8303-8E8FAE099D31}
{857BF156-74BE-4D71-8814-A1ECAA958C2D} = {5C7976B4-C243-41B9-8303-8E8FAE099D31}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C1202A0F-83CC-4602-BCE5-20CB640BCAD4}
Expand Down
5 changes: 5 additions & 0 deletions framework/Publish.bat
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ dotnet pack src/Bing.Logs.Log4Net -c Release -o nuget_pub
dotnet pack src/Bing.Logs.NLog -c Release -o nuget_pub
dotnet pack src/Bing.Logs.Serilog -c Release -o nuget_pub

::Logging
dotnet pack src/Bing.Logging -c Release -o nuget_pub
dotnet pack src/Bing.Logging.Serilog -c Release -o nuget_pub
dotnet pack src/Bing.Logging.Sinks.Exceptionless -c Release -o nuget_pub

::Data
dotnet pack src/Bing.Data -c Release -o nuget_pub
dotnet pack src/Bing.Data.Sql -c Release -o nuget_pub
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="project.props" />

<Import Project="project.dependency.props" />

<Import Project="..\..\..\common.props" />

<ItemGroup>
<Folder Include="Bing\AspNetCore\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Bing.Identity.JwtBearer.Abstractions
{
/// <summary>
/// Jwy刷新令牌存储器
/// </summary>
public interface IRefreshTokenStore
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(MicrosoftPackageVersion)" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>NETSTANDARD</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<DefineConstants>NETCOREAPP3_1</DefineConstants>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Bing.Security\Bing.Security.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<AssemblyName>Bing.AspNetCore.Authentication.JwtBearer</AssemblyName>
<PackageId>Bing.AspNetCore.Authentication.JwtBearer</PackageId>
<Description>Bing.AspNetCore.Authentication.JwtBearer 是Bing应用框架的基于Jwt授权类库。</Description>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Threading.Tasks;
using Bing.DependencyInjection;
using Bing.Extensions;
using Bing.Helpers;
using Bing.IO;
using Bing.Logs;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<ItemGroup>
<PackageReference Include="Bing.Utils.Http" Version="1.2.3" />
<PackageReference Include="Bing.Utils.Http" Version="$(BingUtilsPackageVersion)" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
using System.Threading.Tasks;
using System;
using System.Text;
using System.Threading.Tasks;
using Bing.AspNetCore.ExceptionHandling;
using Bing.DependencyInjection;
using Bing.ExceptionHandling;
using Bing.Helpers;
using Bing.Http;
using Bing.Utils.Json;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;

namespace Bing.AspNetCore.Mvc.ExceptionHandling
{
Expand Down Expand Up @@ -31,7 +40,7 @@ protected virtual bool ShouldHandleException(ExceptionContext context)
{
if (context.ActionDescriptor.IsControllerAction() && context.ActionDescriptor.HasObjectResult())
return true;
if (context.HttpContext.Request.CanAccept("application/json"))
if (context.HttpContext.Request.CanAccept(MimeTypes.Application.Json))
return true;
if (context.HttpContext.Request.IsAjax())
return true;
Expand All @@ -44,6 +53,28 @@ protected virtual bool ShouldHandleException(ExceptionContext context)
/// <param name="context">异常上下文</param>
protected virtual async Task HandleAndWrapException(ExceptionContext context)
{
context.HttpContext.Response.Headers.Add(BingHttpConst.BingErrorFormat, "true");
context.HttpContext.Response.StatusCode = (int)context
.GetRequiredService<IHttpExceptionStatusCodeFinder>()
.GetStatusCode(context.HttpContext, context.Exception);

var exceptionHandlingOptions = context.GetRequiredService<IOptions<BingExceptionHandlingOptions>>().Value;
var exceptionToErrorInfoConverter = context.GetRequiredService<IExceptionToErrorInfoConverter>();
var remoteServiceErrorInfo = exceptionToErrorInfoConverter.Convert(context.Exception, exceptionHandlingOptions.SendExceptionDetailsToClients);

// TODO: 此处考虑是否还要抽象个对象存放信息
context.Result = new ApiResult(Conv.ToInt(remoteServiceErrorInfo.Code), remoteServiceErrorInfo.Message);

var logLevel = context.Exception.GetLogLevel();

var remoteServiceErrorInfoBuilder = new StringBuilder();
remoteServiceErrorInfoBuilder.AppendLine($"---------- {nameof(RemoteServiceErrorInfo)} ----------");
remoteServiceErrorInfoBuilder.AppendLine(JsonHelper.ToJson(remoteServiceErrorInfo, indented: true));

var logger = context.GetService<ILogger<BingExceptionFilter>>(NullLogger<BingExceptionFilter>.Instance);
logger.LogWithLevel(logLevel,remoteServiceErrorInfoBuilder.ToString());
logger.LogException(context.Exception,logLevel);

await context.GetRequiredService<IExceptionNotifier>().NotifyAsync(new ExceptionNotificationContext(context.Exception));
context.Exception = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Bing.AspNetCore.Cors
{
/// <summary>
/// 允许CORS请求中间件
/// 跨域中间件
/// </summary>
public class AllowCorsRequestMiddleware : IMiddleware
{
Expand All @@ -25,6 +25,7 @@ public class AllowCorsRequestMiddleware : IMiddleware
/// <param name="context">Http上下文</param>
public async Task InvokeAsync(HttpContext context)
{
// 若为OPTIONS跨域请求则直接返回,不进入后续管道
if (context.Request.Method.ToLower() == "options")
{
context.Response.StatusCode = StatusCodes.Status202Accepted;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Bing.AspNetCore.ExceptionHandling
{
/// <summary>
/// 授权异常处理器选项配置
/// </summary>
public class BingAuthorizationExceptionHandlerOptions
{
/// <summary>
/// 认证方案
/// </summary>
public string AuthenticationScheme { get; set; }
}
}
Loading

0 comments on commit 811c092

Please sign in to comment.