From b96da94f92a5a22ec1e51ea87655fb5daa8dd960 Mon Sep 17 00:00:00 2001 From: Quentin de Quelen Date: Thu, 7 May 2020 17:01:14 +0200 Subject: [PATCH] fix issues from review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Renault --- CHANGELOG.md | 4 ++-- meilisearch-http/src/error.rs | 4 ++-- meilisearch-http/src/helpers/normalize_slashes.rs | 3 ++- meilisearch-http/src/lib.rs | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dce7f160d..f0b1ace8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,10 @@ - Add support for faceted search (#631) - Add support for configuring the lmdb map size (#646, #647) - Add exposed port for Dockerfile (#654) - - Add sentry probe + - Add sentry probe (#664) - Fix url trailing slash and double slash issues (#659) - Fix accept all Content-Type by default (#653) - - Return the error message from Serde when a deserialization error is encountered + - Return the error message from Serde when a deserialization error is encountered (#661) ## v0.10.1 diff --git a/meilisearch-http/src/error.rs b/meilisearch-http/src/error.rs index 1fa0c5499..e79cb56b6 100644 --- a/meilisearch-http/src/error.rs +++ b/meilisearch-http/src/error.rs @@ -201,10 +201,10 @@ impl From for ResponseError { impl From for ResponseError { fn from(err: JsonPayloadError) -> ResponseError { match err { - JsonPayloadError::Deserialize(err) => ResponseError::BadRequest(format!("BAD_JSON: {}", err)), + JsonPayloadError::Deserialize(err) => ResponseError::BadRequest(format!("Invalid JSON: {}", err)), JsonPayloadError::Overflow => ResponseError::PayloadTooLarge, JsonPayloadError::ContentType => ResponseError::UnsupportedMediaType, - JsonPayloadError::Payload(err) => ResponseError::BadRequest(format!("Problem decoding request: {}", err)), + JsonPayloadError::Payload(err) => ResponseError::BadRequest(format!("Problem while decoding the request: {}", err)), } } } diff --git a/meilisearch-http/src/helpers/normalize_slashes.rs b/meilisearch-http/src/helpers/normalize_slashes.rs index ed2650690..2e19cd889 100644 --- a/meilisearch-http/src/helpers/normalize_slashes.rs +++ b/meilisearch-http/src/helpers/normalize_slashes.rs @@ -2,6 +2,7 @@ /// This middleware normalizes slashes in paths /// * consecutive instances of `/` get collapsed into one `/` /// * any ending `/` is removed. +/// Original source from: https://gitlab.com/snippets/1884466 /// /// Ex: /// /this///url/ @@ -69,7 +70,7 @@ where let path = match parts.path_and_query.as_ref().map(|pq| pq.query()).flatten() { Some(q) => bytes::Bytes::from(format!("{}?{}", new_path, q)), - None =>bytes::Bytes::from(format!("{}", new_path)) + None => bytes::Bytes::from(new_path.to_string()), }; if let Ok(pq) = PathAndQuery::from_maybe_shared(path) { diff --git a/meilisearch-http/src/lib.rs b/meilisearch-http/src/lib.rs index c4445ed3d..465f96caa 100644 --- a/meilisearch-http/src/lib.rs +++ b/meilisearch-http/src/lib.rs @@ -31,7 +31,7 @@ pub fn create_app( .app_data(web::Data::new(data.clone())) .app_data( web::JsonConfig::default() - .limit(1024 * 1024 * 10) + .limit(1024 * 1024 * 10) // Json Limit of 10Mb .content_type(|_mime| true) // Accept all mime types .error_handler(|err, _req| json_error_handler(err).into()), )