Enhancement: Routes with no body should return 204 No Content.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::notifications::events::ClientboundNotification;
|
||||
use crate::util::result::{Error, Result};
|
||||
use crate::util::result::{Error, Result, EmptyResponse};
|
||||
use crate::{database::*, notifications::events::RemoveChannelField};
|
||||
|
||||
use mongodb::bson::{doc, to_document};
|
||||
@@ -21,7 +21,7 @@ pub struct Data {
|
||||
}
|
||||
|
||||
#[patch("/<target>", data = "<data>")]
|
||||
pub async fn req(user: User, target: Ref, data: Json<Data>) -> Result<()> {
|
||||
pub async fn req(user: User, target: Ref, data: Json<Data>) -> Result<EmptyResponse> {
|
||||
let data = data.into_inner();
|
||||
data.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
@@ -31,7 +31,7 @@ pub async fn req(user: User, target: Ref, data: Json<Data>) -> Result<()> {
|
||||
&& data.icon.is_none()
|
||||
&& data.remove.is_none()
|
||||
{
|
||||
return Ok(());
|
||||
return Ok(EmptyResponse {});
|
||||
}
|
||||
|
||||
let target = target.fetch_channel().await?;
|
||||
@@ -146,7 +146,7 @@ pub async fn req(user: User, target: Ref, data: Json<Data>) -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(EmptyResponse {})
|
||||
}
|
||||
_ => Err(Error::InvalidOperation),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user