232: Fix payload size limit r=MarinPostma a=MarinPostma

Fix #223

This was due to the fact that Payload ignores the limit payload size limit. I fixed it by implementing my own `Payload` extractor that checks that the size of the payload is not too large.

I also refactored the `create_app` a bit.

Co-authored-by: marin postma <postma.marin@protonmail.com>
This commit is contained in:
bors[bot] 2021-06-23 16:06:08 +00:00 committed by GitHub
commit 8638c9ab77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 231 additions and 110 deletions

View file

@ -1,4 +1,3 @@
use actix_web::web::Payload;
use actix_web::{delete, get, post, put};
use actix_web::{web, HttpResponse};
use indexmap::IndexMap;
@ -8,6 +7,7 @@ use serde::Deserialize;
use serde_json::Value;
use crate::error::ResponseError;
use crate::extractors::payload::Payload;
use crate::helpers::Authentication;
use crate::routes::IndexParam;
use crate::Data;
@ -174,7 +174,7 @@ async fn update_documents(
data: web::Data<Data>,
path: web::Path<IndexParam>,
params: web::Query<UpdateDocumentsQuery>,
body: web::Payload,
body: Payload,
) -> Result<HttpResponse, ResponseError> {
let update = data
.add_documents(

View file

@ -6,7 +6,7 @@ use serde_json::Value;
use crate::error::ResponseError;
use crate::helpers::Authentication;
use crate::index::{SearchQuery, default_crop_length, DEFAULT_SEARCH_LIMIT};
use crate::index::{default_crop_length, SearchQuery, DEFAULT_SEARCH_LIMIT};
use crate::routes::IndexParam;
use crate::Data;