1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use super::errors::HandleError;
use serde::Serialize;
use warp::reply::Response;
use warp::Reply;

pub struct HandlerResult<T>(pub Result<T, HandleError>);

impl<T: Send + Serialize> Reply for HandlerResult<T> {
    fn into_response(self) -> Response {
        match self.0 {
            Ok(res) => warp::reply::json(&res).into_response(),
            Err(error) => error.into_response(),
        }
    }
}