From 49ebb2792ec93d4bc0cbcb34d388ffbfacbb7b61 Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Mon, 7 Oct 2024 14:22:31 +0800 Subject: [PATCH] Add new namespaces and improve RewriteOptions readability Added several `using` directives in `Program.cs` for new functionalities and dependencies. Modified `RewriteOptions` configuration to use `HttpStatusCode.MovedPermanently` instead of a hardcoded integer for better readability and maintainability. --- src/Moonglade.Web/Program.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Moonglade.Web/Program.cs b/src/Moonglade.Web/Program.cs index e5e048a5f..2139e1891 100644 --- a/src/Moonglade.Web/Program.cs +++ b/src/Moonglade.Web/Program.cs @@ -1,4 +1,5 @@ using System.Globalization; +using System.Net; using System.Text.Json.Serialization; using Edi.Captcha; using Edi.PasswordGenerator; @@ -286,7 +287,7 @@ private static void ConfigureMiddleware(WebApplication app, List cu SupportedUICultures = cultures }); - var options = new RewriteOptions().AddRedirect(@"(.*)/$", @"\$1", 301); + var options = new RewriteOptions().AddRedirect(@"(.*)/$", @"\$1", (int)HttpStatusCode.MovedPermanently); app.UseRewriter(options); app.UseStaticFiles(); app.UseSession().UseCaptchaImage(p =>