Enhancement: Routes with no body should return 204 No Content.

This commit is contained in:
heikkari
2021-08-16 15:34:44 +03:00
parent 48d2fbe5ae
commit 721ca3a4f5
30 changed files with 124 additions and 116 deletions

View File

@@ -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::RemoveBotField};
use mongodb::bson::doc;
@@ -25,7 +25,7 @@ pub struct Data {
}
#[patch("/<target>", data = "<data>")]
pub async fn edit_bot(user: User, target: Ref, data: Json<Data>) -> Result<()> {
pub async fn edit_bot(user: User, target: Ref, data: Json<Data>) -> Result<EmptyResponse> {
let data = data.into_inner();
data.validate()
.map_err(|error| Error::FailedValidation { error })?;
@@ -112,5 +112,5 @@ pub async fn edit_bot(user: User, target: Ref, data: Json<Data>) -> Result<()> {
})?;
}
Ok(())
Ok(EmptyResponse {})
}