pub trait HttpContext<T> {
// Required methods
fn http_context<C>(
self,
status_code: StatusCode,
extra_msg: C,
) -> Result<T, HttpError>
where C: Display + Send + Sync + 'static;
fn http_error<C>(self, extra_msg: C) -> Result<T, HttpError>
where C: Display + Send + Sync + 'static;
}
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(())
}
Required Methods§
fn http_context<C>( self, status_code: StatusCode, extra_msg: C, ) -> Result<T, HttpError>
fn http_error<C>(self, extra_msg: C) -> Result<T, HttpError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.