Trait spa_rs::HttpContext
source · [−]pub trait HttpContext<T> {
fn http_context<C>(
self,
status_code: StatusCode,
extra_msg: C
) -> Result<T, HttpError>
where
C: 'static + Display + Send + Sync;
fn http_error<C>(self, extra_msg: C) -> Result<T, HttpError>
where
C: 'static + Display + Send + Sync;
}Expand description
Easily convert std::result::Result to HttpResult
Example
fn handler() -> HttpResult<()> {
result.http_context(StatusCode::BAD_REQUEST, "bad request")?;
result.http_error("bad request")?;
Ok(())
}