mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 03:55:07 +08:00
Tidy up code
This commit is contained in:
parent
c713bd2a9c
commit
8536d4448a
@ -59,9 +59,10 @@ where
|
|||||||
type Output = Result<ValidatedJson<T, E>, actix_web::Error>;
|
type Output = Result<ValidatedJson<T, E>, actix_web::Error>;
|
||||||
|
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
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 {
|
let res = match res {
|
||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
|
@ -84,17 +84,19 @@ pub fn configure_data(
|
|||||||
web::JsonConfig::default()
|
web::JsonConfig::default()
|
||||||
.content_type(|mime| mime == mime::APPLICATION_JSON)
|
.content_type(|mime| mime == mime::APPLICATION_JSON)
|
||||||
.error_handler(|err, req: &HttpRequest| match err {
|
.error_handler(|err, req: &HttpRequest| match err {
|
||||||
JsonPayloadError::ContentType => match req.headers().get(CONTENT_TYPE) {
|
JsonPayloadError::ContentType => {
|
||||||
Some(content_type) => MeilisearchHttpError::InvalidContentType(
|
match req.headers().get(CONTENT_TYPE) {
|
||||||
content_type.to_str().unwrap_or("unknown").to_string(),
|
Some(content_type) => MeilisearchHttpError::InvalidContentType(
|
||||||
vec![mime::APPLICATION_JSON.to_string()],
|
content_type.to_str().unwrap_or("unknown").to_string(),
|
||||||
)
|
vec![mime::APPLICATION_JSON.to_string()],
|
||||||
.into(),
|
)
|
||||||
None => MeilisearchHttpError::MissingContentType(vec![
|
.into(),
|
||||||
mime::APPLICATION_JSON.to_string(),
|
None => MeilisearchHttpError::MissingContentType(vec![
|
||||||
])
|
mime::APPLICATION_JSON.to_string(),
|
||||||
.into(),
|
])
|
||||||
},
|
.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
err => PayloadError::from(err).into(),
|
err => PayloadError::from(err).into(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user