Added http debug middleware to trace requests
This commit is contained in:
parent
e47a4c29f7
commit
456d87f262
3 changed files with 26 additions and 1 deletions
20
Moonlight/Core/Http/Middleware/DebugLogMiddleware.cs
Normal file
20
Moonlight/Core/Http/Middleware/DebugLogMiddleware.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
using MoonCore.Helpers;
|
||||||
|
|
||||||
|
namespace Moonlight.Core.Http.Middleware;
|
||||||
|
|
||||||
|
public class DebugLogMiddleware
|
||||||
|
{
|
||||||
|
private RequestDelegate Next;
|
||||||
|
|
||||||
|
public DebugLogMiddleware(RequestDelegate next)
|
||||||
|
{
|
||||||
|
Next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Invoke(HttpContext context)
|
||||||
|
{
|
||||||
|
Logger.Debug($"[{context.Request.Method.ToUpper()}] {context.Request.Path}");
|
||||||
|
|
||||||
|
await Next(context);
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,7 +51,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Core\Database\Migrations\" />
|
<Folder Include="Core\Database\Migrations\" />
|
||||||
<Folder Include="Core\Http\Middleware\" />
|
|
||||||
<Folder Include="Core\Http\Requests\" />
|
<Folder Include="Core\Http\Requests\" />
|
||||||
<Folder Include="Core\Http\Resources\" />
|
<Folder Include="Core\Http\Resources\" />
|
||||||
<Folder Include="Core\UI\Components\Forms\" />
|
<Folder Include="Core\UI\Components\Forms\" />
|
||||||
|
|
|
@ -4,6 +4,7 @@ using MoonCore.Helpers;
|
||||||
using MoonCore.Services;
|
using MoonCore.Services;
|
||||||
using Moonlight.Core.Configuration;
|
using Moonlight.Core.Configuration;
|
||||||
using Moonlight.Core.Database;
|
using Moonlight.Core.Database;
|
||||||
|
using Moonlight.Core.Http.Middleware;
|
||||||
using Moonlight.Core.Services;
|
using Moonlight.Core.Services;
|
||||||
|
|
||||||
// Create needed storage directories
|
// Create needed storage directories
|
||||||
|
@ -100,4 +101,9 @@ await pluginService.Initialized(app);
|
||||||
|
|
||||||
app.Services.StartBackgroundServices<Program>();
|
app.Services.StartBackgroundServices<Program>();
|
||||||
|
|
||||||
|
if (Environment.GetEnvironmentVariables().Contains("DEBUG_HTTP"))
|
||||||
|
{
|
||||||
|
app.UseMiddleware<DebugLogMiddleware>();
|
||||||
|
}
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
Loading…
Reference in a new issue