refactor: for maintenance mode, return the standard error

This commit is contained in:
2024-12-22 05:51:11 +03:00
parent 7bafbb95c4
commit 7b94f9cc1f
3 changed files with 21 additions and 7 deletions

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Http;
using Mirea.Api.Endpoint.Common.Attributes;
using Mirea.Api.Endpoint.Common.Exceptions;
using Mirea.Api.Endpoint.Common.Interfaces;
using System.Threading.Tasks;
@ -25,13 +26,10 @@ public class MaintenanceModeMiddleware(RequestDelegate next, IMaintenanceModeSer
string error;
if (maintenanceModeService.IsMaintenanceMode)
{
context.Response.Headers.RetryAfter = "600";
error = "The service is currently undergoing maintenance. Please try again later.";
}
else
error =
"The service is currently not configured. Go to the setup page if you are an administrator or try again later.";
throw new ServerUnavailableException("The service is currently undergoing maintenance. Please try again later.", true);
throw new ServerUnavailableException(
"The service is currently not configured. Go to the setup page if you are an administrator or try again later.", false);
await context.Response.WriteAsync(error);
}