94: remove guard on document addition routes r=curquiza a=MarinPostma

 Remove `application/json` guards on document addition routes.

Co-authored-by: mpostma <postma.marin@protonmail.com>
This commit is contained in:
bors[bot] 2021-03-16 12:52:43 +00:00 committed by GitHub
commit e0c5740050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,7 @@ const DEFAULT_RETRIEVE_DOCUMENTS_LIMIT: usize = 20;
macro_rules! guard_content_type { macro_rules! guard_content_type {
($fn_name:ident, $guard_value:literal) => { ($fn_name:ident, $guard_value:literal) => {
#[allow(dead_code)]
fn $fn_name(head: &actix_web::dev::RequestHead) -> bool { fn $fn_name(head: &actix_web::dev::RequestHead) -> bool {
if let Some(content_type) = head.headers.get("Content-Type") { if let Some(content_type) = head.headers.get("Content-Type") {
content_type content_type
@ -44,7 +45,7 @@ pub fn services(cfg: &mut web::ServiceConfig) {
cfg.service(get_document) cfg.service(get_document)
.service(delete_document) .service(delete_document)
.service(get_all_documents) .service(get_all_documents)
.service(add_documents_json) .service(add_documents)
.service(update_documents) .service(update_documents)
.service(delete_documents) .service(delete_documents)
.service(clear_all_documents); .service(clear_all_documents);
@ -144,9 +145,8 @@ struct UpdateDocumentsQuery {
#[post( #[post(
"/indexes/{index_uid}/documents", "/indexes/{index_uid}/documents",
wrap = "Authentication::Private", wrap = "Authentication::Private",
guard = "guard_json"
)] )]
async fn add_documents_json( async fn add_documents(
data: web::Data<Data>, data: web::Data<Data>,
path: web::Path<IndexParam>, path: web::Path<IndexParam>,
params: web::Query<UpdateDocumentsQuery>, params: web::Query<UpdateDocumentsQuery>,
@ -201,7 +201,6 @@ async fn update_documents_default(
#[put( #[put(
"/indexes/{index_uid}/documents", "/indexes/{index_uid}/documents",
wrap = "Authentication::Private", wrap = "Authentication::Private",
guard = "guard_json"
)] )]
async fn update_documents( async fn update_documents(
data: web::Data<Data>, data: web::Data<Data>,