mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-02-22 20:52:27 +00:00
add ResourceResult impl for Result<AuthResult<T>, E>
This commit is contained in:
parent
523d01d443
commit
45cad64923
1 changed files with 36 additions and 0 deletions
|
@ -406,6 +406,42 @@ impl<T : ResourceResult> ResourceResult for AuthResult<T>
|
|||
}
|
||||
}
|
||||
|
||||
impl<T : ResourceResult<Err = SerdeJsonError>, E : Error> ResourceResult for Result<AuthResult<T>, E>
|
||||
{
|
||||
type Err = T::Err;
|
||||
|
||||
fn into_response(self) -> Pin<Box<dyn Future<Output = Result<Response, T::Err>> + Send>>
|
||||
{
|
||||
match self {
|
||||
Ok(r) => r.into_response(),
|
||||
Err(e) => {
|
||||
into_response_helper(|| {
|
||||
errorlog(&e);
|
||||
let err : ResourceError = e.into();
|
||||
Ok(Response::json(StatusCode::INTERNAL_SERVER_ERROR, serde_json::to_string(&err)?))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn accepted_types() -> Option<Vec<Mime>>
|
||||
{
|
||||
T::accepted_types()
|
||||
}
|
||||
|
||||
#[cfg(feature = "openapi")]
|
||||
fn schema() -> OpenapiSchema
|
||||
{
|
||||
T::schema()
|
||||
}
|
||||
|
||||
#[cfg(feature = "openapi")]
|
||||
fn default_status() -> StatusCode
|
||||
{
|
||||
T::default_status()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
This is the return type of a resource that doesn't actually return something. It will result
|
||||
in a _204 No Content_ answer by default. You don't need to use this type directly if using
|
||||
|
|
Loading…
Add table
Reference in a new issue