Add a responder for empty responses

This commit is contained in:
heikkari
2021-08-16 14:05:59 +03:00
parent c1d03960ed
commit 48d2fbe5ae

View File

@@ -68,8 +68,17 @@ pub enum Error {
NoEffect,
}
pub struct EmptyResponse;
pub type Result<T, E = Error> = std::result::Result<T, E>;
impl<'r> Responder<'r> for EmptyResponse {
fn respond_to(self, req: &Request) -> response::Result<'r> {
Response::build()
.status(rocket::http::Status { code: 204 })
.ok()
}
}
/// HTTP response builder for Error enum
impl<'r> Responder<'r, 'static> for Error {
fn respond_to(self, _: &'r Request<'_>) -> response::Result<'static> {