From 8536d4448a741ed30a9f611aed649ac091e6f49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Wed, 22 Jun 2022 16:15:10 +0200 Subject: [PATCH] Tidy up code --- meilisearch-http/src/extractors/jayson.rs | 5 +++-- meilisearch-http/src/lib.rs | 24 ++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/meilisearch-http/src/extractors/jayson.rs b/meilisearch-http/src/extractors/jayson.rs index 20a03dfb2..aaa370fbe 100644 --- a/meilisearch-http/src/extractors/jayson.rs +++ b/meilisearch-http/src/extractors/jayson.rs @@ -59,9 +59,10 @@ where type Output = Result, actix_web::Error>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let this = self.get_mut(); + let ValidatedJsonExtractFut { fut, .. } = self.get_mut(); + let fut = Pin::new(fut); - let res = ready!(Pin::new(&mut this.fut).poll(cx)); + let res = ready!(fut.poll(cx)); let res = match res { Err(err) => Err(err), diff --git a/meilisearch-http/src/lib.rs b/meilisearch-http/src/lib.rs index bfdb829d4..9f15d90e8 100644 --- a/meilisearch-http/src/lib.rs +++ b/meilisearch-http/src/lib.rs @@ -84,17 +84,19 @@ pub fn configure_data( web::JsonConfig::default() .content_type(|mime| mime == mime::APPLICATION_JSON) .error_handler(|err, req: &HttpRequest| match err { - JsonPayloadError::ContentType => match req.headers().get(CONTENT_TYPE) { - Some(content_type) => MeilisearchHttpError::InvalidContentType( - content_type.to_str().unwrap_or("unknown").to_string(), - vec![mime::APPLICATION_JSON.to_string()], - ) - .into(), - None => MeilisearchHttpError::MissingContentType(vec![ - mime::APPLICATION_JSON.to_string(), - ]) - .into(), - }, + JsonPayloadError::ContentType => { + match req.headers().get(CONTENT_TYPE) { + Some(content_type) => MeilisearchHttpError::InvalidContentType( + content_type.to_str().unwrap_or("unknown").to_string(), + vec![mime::APPLICATION_JSON.to_string()], + ) + .into(), + None => MeilisearchHttpError::MissingContentType(vec![ + mime::APPLICATION_JSON.to_string(), + ]) + .into(), + } + } err => PayloadError::from(err).into(), }), )