Skip to content

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
vahid committed Nov 2, 2024
1 parent 0ca4ce2 commit 11bb369
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ public static class IServiceCollectionExtensions
{
public static void ConfigureJingetExceptionHandler(this IServiceCollection services, BaseSettingModel baseSetting)
{
services.TryAddSingleton(baseSetting);
if (baseSetting.UseGlobalExceptionHandler)
{
services.TryAddSingleton(baseSetting);
services.AddProblemDetails();

if (baseSetting.Handle4xxResponses)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ public static class IApplicationBuilderExtensions
/// </summary>
public static IApplicationBuilder UseJingetLogging(this IApplicationBuilder app)
{
app.UseJingetExceptionHandler();
var settings = app.ApplicationServices.GetJingetService<BaseSettingModel>();

if (settings != null && settings.UseGlobalExceptionHandler)
app.UseJingetExceptionHandler();
app.UseMiddleware<LogRequestMiddleware>();
app.UseMiddleware<LogResponseMiddleware>();

Expand Down
2 changes: 1 addition & 1 deletion Tests/Jinget.WebAPI.Tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Url = "localhost:9200",
UseSsl = false,
UseGlobalExceptionHandler = true,
Handle4xxResponses = true
Handle4xxResponses = false
};
builder.Services.ConfigureElasticSearchLogger(elasticSearchSetting);
builder.Services.AddControllers();
Expand Down

0 comments on commit 11bb369

Please sign in to comment.