Adds media libraries management view

This commit is contained in:
BinaryAlley committed 2025-01-11 23:11:33 +02:00
1 parent b593cbce93
commit d7c8478101
162 files changed
+3741 -171

No files matched your search

@@ -1,5 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Localization;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
#endregion
@@ -11,14 +13,17 @@ namespace Lumina.Presentation.Web.Common.Middlewares;
public class NotFoundRedirectMiddleware
{
private readonly RequestDelegate _next;
private readonly ILogger<NotFoundRedirectMiddleware> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="NotFoundRedirectMiddleware"/> class.
/// </summary>
/// <param name="next">The next middleware in the request pipeline.</param>
public NotFoundRedirectMiddleware(RequestDelegate next)
/// <param name="logger">Injected service for logging.</param>
public NotFoundRedirectMiddleware(RequestDelegate next, ILogger<NotFoundRedirectMiddleware> logger)
{
_next = next;
_logger = logger;
}
/// <summary>
@@ -26,18 +31,20 @@ public class NotFoundRedirectMiddleware
/// </summary>
/// <param name="context">The <see cref="HttpContext"/> for the current request.</param>
public async Task InvokeAsync(HttpContext context)
{
{
await _next(context);
if (context.Response.StatusCode == 404 && !context.Response.HasStarted)
{
string culture = context.Request.RouteValues["culture"]?.ToString()?.ToLower() ?? "en-us";
string notFoundUrl = $"/{culture}/not-found";
string culture = context.Request.RouteValues["culture"]?.ToString()?.ToLower() ??
context.Features.Get<IRequestCultureFeature>()?.RequestCulture.Culture.Name?.ToLower() ??
"en-us";
// re-execute the request so the user gets the error page
string? originalPath = context.Request.Path.Value;
context.Items["originalPath"] = originalPath;
context.Request.Path = notFoundUrl;
_logger.LogInformation("Redirecting user to NotFound url");
context.Request.Path = $"/{culture}/not-found";
await _next(context);
}
}