use std::fmt::{self, Display, Formatter};
use warp::reject::Reject;
#[derive(Debug)]
pub(crate) struct UnsupportedMediaType;
impl Display for UnsupportedMediaType {
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), fmt::Error> {
formatter.write_str("The request's content-type is not supported")
}
}
impl Reject for UnsupportedMediaType {}
#[derive(Debug)]
pub(crate) struct MissingContentTypeHeader;
impl Display for MissingContentTypeHeader {
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), fmt::Error> {
formatter.write_str("The request's content-type is not set")
}
}
impl Reject for MissingContentTypeHeader {}
#[derive(Debug)]
pub(crate) struct MissingId;
impl Display for MissingId {
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), fmt::Error> {
formatter.write_str("The request is missing the 'id' field")
}
}
impl Reject for MissingId {}
#[derive(Debug)]
pub(crate) struct BodyTooLarge(pub(crate) u32);
impl Display for BodyTooLarge {
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result<(), fmt::Error> {
write!(
formatter,
"The request payload exceeds the maximum allowed of {} bytes",
self.0
)
}
}
impl Reject for BodyTooLarge {}