From 655db2827eb465d931651a4ce7be087d8469ec2e Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Sun, 17 Nov 2024 15:25:30 +0800 Subject: [PATCH] Refactor health check response writer to new class Moved WriteResponse method from ConfigureEndpoints to new PingEndpoint class. Updated Program.cs to reference PingEndpoint.WriteResponse. Created PingEndpoint.cs with WriteResponse method. Removed WriteResponse method from ConfigureEndpoints. --- .../Configuration/{ConfigureEndpoints.cs => PingEndpoint.cs} | 2 +- src/Moonglade.Web/Program.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/Moonglade.Web/Configuration/{ConfigureEndpoints.cs => PingEndpoint.cs} (93%) diff --git a/src/Moonglade.Web/Configuration/ConfigureEndpoints.cs b/src/Moonglade.Web/Configuration/PingEndpoint.cs similarity index 93% rename from src/Moonglade.Web/Configuration/ConfigureEndpoints.cs rename to src/Moonglade.Web/Configuration/PingEndpoint.cs index 5c75d1ed6..db9a520d7 100644 --- a/src/Moonglade.Web/Configuration/ConfigureEndpoints.cs +++ b/src/Moonglade.Web/Configuration/PingEndpoint.cs @@ -2,7 +2,7 @@ namespace Moonglade.Web.Configuration; -public class ConfigureEndpoints +public class PingEndpoint { public static Task WriteResponse(HttpContext context, HealthReport result) { diff --git a/src/Moonglade.Web/Program.cs b/src/Moonglade.Web/Program.cs index fb7249ace..3fe527825 100644 --- a/src/Moonglade.Web/Program.cs +++ b/src/Moonglade.Web/Program.cs @@ -308,7 +308,7 @@ private static void ConfigureMiddleware(WebApplication app, List cu app.MapHealthChecks("/ping", new() { - ResponseWriter = ConfigureEndpoints.WriteResponse + ResponseWriter = PingEndpoint.WriteResponse }); app.MapControllers(); app.MapRazorPages();