mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-02-23 04:52:28 +00:00
allow Result<NoContent> responses
This commit is contained in:
parent
a28ccb98f1
commit
75c399d97a
1 changed files with 26 additions and 0 deletions
|
@ -123,3 +123,29 @@ impl ResourceResult for NoContent
|
||||||
StatusCode::NO_CONTENT
|
StatusCode::NO_CONTENT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<E : Error> ResourceResult for Result<NoContent, E>
|
||||||
|
{
|
||||||
|
fn to_json(&self) -> Result<(StatusCode, String), SerdeJsonError>
|
||||||
|
{
|
||||||
|
Ok(match self {
|
||||||
|
Ok(_) => (StatusCode::NO_CONTENT, "".to_string()),
|
||||||
|
Err(e) => {
|
||||||
|
let err : ResourceError = e.into();
|
||||||
|
(StatusCode::INTERNAL_SERVER_ERROR, serde_json::to_string(&err)?)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "openapi")]
|
||||||
|
fn to_schema() -> OpenapiSchema
|
||||||
|
{
|
||||||
|
<()>::to_schema()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "openapi")]
|
||||||
|
fn default_status() -> StatusCode
|
||||||
|
{
|
||||||
|
StatusCode::NO_CONTENT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue