makes the content-type mandatory for every routes

This commit is contained in:
Tamo 2021-10-05 13:30:53 +02:00
parent ddbcf449da
commit c6d107a05f
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
4 changed files with 61 additions and 14 deletions

View file

@ -181,9 +181,24 @@ async fn document_addition(
Some("application/x-ndjson") => DocumentAdditionFormat::Ndjson,
Some("text/csv") => DocumentAdditionFormat::Csv,
Some(other) => {
return Err(MeilisearchHttpError::InvalidContentType(other.to_string()).into())
return Err(MeilisearchHttpError::InvalidContentType(
other.to_string(),
vec![
"application/json".to_string(),
"application/x-ndjson".to_string(),
"application/csv".to_string(),
],
)
.into())
}
None => {
return Err(MeilisearchHttpError::MissingContentType(vec![
"application/json".to_string(),
"application/x-ndjson".to_string(),
"application/csv".to_string(),
])
.into())
}
None => return Err(MeilisearchHttpError::MissingContentType.into()),
};
let update = Update::DocumentAddition {