use http::StatusCode;
use topcoat_core::{context::Cx, error::Result};
use crate::response::{IntoResponse, Response};
#[must_use]
pub fn unauthorized() -> UnauthorizedError {
UnauthorizedError::new()
}
#[derive(Debug)]
pub struct UnauthorizedError {
_priv: (),
}
impl UnauthorizedError {
fn new() -> Self {
Self { _priv: () }
}
}
impl std::fmt::Display for UnauthorizedError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("unauthorized")
}
}
impl std::error::Error for UnauthorizedError {}
impl IntoResponse for UnauthorizedError {
fn into_response(self, cx: &Cx) -> Result<Response> {
(StatusCode::UNAUTHORIZED, "unauthorized").into_response(cx)
}
}