mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-30 19:34:37 +00:00
Update Rust Edition to 2024 (#7766)
* #7749 Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
@@ -20,12 +20,12 @@ pub fn json<T: DeserializeOwned + Send>() -> impl Filter<Extract = (T,), Error =
|
||||
warp::header::optional::<String>(CONTENT_TYPE_HEADER)
|
||||
.and(warp::body::bytes())
|
||||
.and_then(|header: Option<String>, bytes: Bytes| async move {
|
||||
if let Some(header) = header {
|
||||
if header == SSZ_CONTENT_TYPE_HEADER {
|
||||
return Err(reject::unsupported_media_type(
|
||||
"The request's content-type is not supported".to_string(),
|
||||
));
|
||||
}
|
||||
if let Some(header) = header
|
||||
&& header == SSZ_CONTENT_TYPE_HEADER
|
||||
{
|
||||
return Err(reject::unsupported_media_type(
|
||||
"The request's content-type is not supported".to_string(),
|
||||
));
|
||||
}
|
||||
Json::decode(bytes)
|
||||
.map_err(|err| reject::custom_deserialize_error(format!("{:?}", err)))
|
||||
@@ -33,17 +33,17 @@ pub fn json<T: DeserializeOwned + Send>() -> impl Filter<Extract = (T,), Error =
|
||||
}
|
||||
|
||||
// Add a json_no_body function to handle the case when no body is provided in the HTTP request
|
||||
pub fn json_no_body<T: DeserializeOwned + Default + Send>(
|
||||
) -> impl Filter<Extract = (T,), Error = Rejection> + Copy {
|
||||
pub fn json_no_body<T: DeserializeOwned + Default + Send>()
|
||||
-> impl Filter<Extract = (T,), Error = Rejection> + Copy {
|
||||
warp::header::optional::<String>(CONTENT_TYPE_HEADER)
|
||||
.and(warp::body::bytes())
|
||||
.and_then(|header: Option<String>, bytes: Bytes| async move {
|
||||
if let Some(header) = header {
|
||||
if header == SSZ_CONTENT_TYPE_HEADER {
|
||||
return Err(reject::unsupported_media_type(
|
||||
"The request's content-type is not supported".to_string(),
|
||||
));
|
||||
}
|
||||
if let Some(header) = header
|
||||
&& header == SSZ_CONTENT_TYPE_HEADER
|
||||
{
|
||||
return Err(reject::unsupported_media_type(
|
||||
"The request's content-type is not supported".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
// Handle the case when the HTTP request has no body, i.e., without the -d header
|
||||
|
||||
Reference in New Issue
Block a user