diff --git a/Moonlight/Core/Http/Middleware/DebugLogMiddleware.cs b/Moonlight/Core/Http/Middleware/DebugLogMiddleware.cs new file mode 100644 index 0000000..3a67927 --- /dev/null +++ b/Moonlight/Core/Http/Middleware/DebugLogMiddleware.cs @@ -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); + } +} \ No newline at end of file diff --git a/Moonlight/Moonlight.csproj b/Moonlight/Moonlight.csproj index 007b8aa..8855c86 100644 --- a/Moonlight/Moonlight.csproj +++ b/Moonlight/Moonlight.csproj @@ -51,7 +51,6 @@ - diff --git a/Moonlight/Program.cs b/Moonlight/Program.cs index 5770dc1..5aa1ae2 100644 --- a/Moonlight/Program.cs +++ b/Moonlight/Program.cs @@ -4,6 +4,7 @@ using MoonCore.Helpers; using MoonCore.Services; using Moonlight.Core.Configuration; using Moonlight.Core.Database; +using Moonlight.Core.Http.Middleware; using Moonlight.Core.Services; // Create needed storage directories @@ -100,4 +101,9 @@ await pluginService.Initialized(app); app.Services.StartBackgroundServices(); +if (Environment.GetEnvironmentVariables().Contains("DEBUG_HTTP")) +{ + app.UseMiddleware(); +} + app.Run(); \ No newline at end of file