fix issues from review

Co-authored-by: Clément Renault <clement@meilisearch.com>
This commit is contained in:
Quentin de Quelen 2020-05-07 17:01:14 +02:00 committed by qdequele
parent 305665cd42
commit b96da94f92
No known key found for this signature in database
GPG Key ID: B3F0A000EBF11745
4 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -201,10 +201,10 @@ impl From<actix_http::Error> for ResponseError {
impl From<JsonPayloadError> 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)),
}
}
}

View File

@ -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) {

View File

@ -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()),
)