mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-17 07:49:45 +02:00
New: Additional logging for InvalidModel BadRequest API calls
[common]
This commit is contained in:
parent
346236764c
commit
f1a00764cd
@ -6,6 +6,7 @@
|
|||||||
using Microsoft.AspNetCore.DataProtection;
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -117,6 +118,21 @@ public void ConfigureServices(IServiceCollection services)
|
|||||||
});
|
});
|
||||||
|
|
||||||
services.AddAppAuthentication();
|
services.AddAppAuthentication();
|
||||||
|
|
||||||
|
services.PostConfigure<ApiBehaviorOptions>(options =>
|
||||||
|
{
|
||||||
|
var builtInFactory = options.InvalidModelStateResponseFactory;
|
||||||
|
|
||||||
|
options.InvalidModelStateResponseFactory = context =>
|
||||||
|
{
|
||||||
|
var loggerFactory = context.HttpContext.RequestServices.GetRequiredService<ILoggerFactory>();
|
||||||
|
var logger = loggerFactory.CreateLogger(context.ActionDescriptor.DisplayName);
|
||||||
|
|
||||||
|
logger.LogError(STJson.ToJson(context.ModelState));
|
||||||
|
|
||||||
|
return builtInFactory(context);
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app,
|
public void Configure(IApplicationBuilder app,
|
||||||
|
Loading…
Reference in New Issue
Block a user