namespace Elternbeirat.Web.Shared;
///
/// Marks the current response as HTTP 503 when the content source is down.
///
///
/// Several components handle a
/// the same way: the site works but PocketBase does not, so the response is a
/// 503 and the component renders a "temporarily unavailable" note instead of
/// empty content that would read as 200 "there is nothing here". This puts the
/// status-setting in one place so those components do not each repeat it.
///
internal static class SourceUnavailable
{
///
/// Sets the response status to 503 Service Unavailable, if there is a
/// response to set it on.
///
///
/// The current HTTP context, or when the component
/// renders outside a request (in which case there is nothing to do).
///
public static void SetStatus(HttpContext? context)
{
if (context is not null)
{
context.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;
}
}
}