chore: fix rustfmt error
This commit is contained in:
@@ -18,8 +18,8 @@ use tokio::net::TcpListener;
|
|||||||
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "typed_multipart",
|
feature = "typed_multipart",
|
||||||
derive(axum_typed_multipart::TryFromMultipart)
|
derive(axum_typed_multipart::TryFromMultipart)
|
||||||
)]
|
)]
|
||||||
pub struct ParametersGarde {
|
pub struct ParametersGarde {
|
||||||
#[garde(range(min = 5, max = 10))]
|
#[garde(range(min = 5, max = 10))]
|
||||||
@@ -76,13 +76,13 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
.route(route::JSON, post(extract_json));
|
.route(route::JSON, post(extract_json));
|
||||||
|
|
||||||
#[cfg(feature = "typed_header")]
|
#[cfg(feature = "typed_header")]
|
||||||
let router = router.route(
|
let router = router.route(
|
||||||
typed_header::route::TYPED_HEADER,
|
typed_header::route::TYPED_HEADER,
|
||||||
post(typed_header::extract_typed_header),
|
post(typed_header::extract_typed_header),
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "typed_multipart")]
|
#[cfg(feature = "typed_multipart")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
typed_multipart::route::TYPED_MULTIPART,
|
typed_multipart::route::TYPED_MULTIPART,
|
||||||
post(typed_multipart::extract_typed_multipart),
|
post(typed_multipart::extract_typed_multipart),
|
||||||
@@ -93,7 +93,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra")]
|
#[cfg(feature = "extra")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(extra::route::CACHED, post(extra::extract_cached))
|
.route(extra::route::CACHED, post(extra::extract_cached))
|
||||||
.route(
|
.route(
|
||||||
extra::route::WITH_REJECTION,
|
extra::route::WITH_REJECTION,
|
||||||
@@ -105,34 +105,34 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_typed_path")]
|
#[cfg(feature = "extra_typed_path")]
|
||||||
let router = router.route(
|
let router = router.route(
|
||||||
extra_typed_path::route::EXTRA_TYPED_PATH,
|
extra_typed_path::route::EXTRA_TYPED_PATH,
|
||||||
get(extra_typed_path::extract_extra_typed_path),
|
get(extra_typed_path::extract_extra_typed_path),
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_query")]
|
#[cfg(feature = "extra_query")]
|
||||||
let router = router.route(
|
let router = router.route(
|
||||||
extra_query::route::EXTRA_QUERY,
|
extra_query::route::EXTRA_QUERY,
|
||||||
post(extra_query::extract_extra_query),
|
post(extra_query::extract_extra_query),
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_form")]
|
#[cfg(feature = "extra_form")]
|
||||||
let router = router.route(
|
let router = router.route(
|
||||||
extra_form::route::EXTRA_FORM,
|
extra_form::route::EXTRA_FORM,
|
||||||
post(extra_form::extract_extra_form),
|
post(extra_form::extract_extra_form),
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_protobuf")]
|
#[cfg(feature = "extra_protobuf")]
|
||||||
let router = router.route(
|
let router = router.route(
|
||||||
extra_protobuf::route::EXTRA_PROTOBUF,
|
extra_protobuf::route::EXTRA_PROTOBUF,
|
||||||
post(extra_protobuf::extract_extra_protobuf),
|
post(extra_protobuf::extract_extra_protobuf),
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "yaml")]
|
#[cfg(feature = "yaml")]
|
||||||
let router = router.route(yaml::route::YAML, post(yaml::extract_yaml));
|
let router = router.route(yaml::route::YAML, post(yaml::extract_yaml));
|
||||||
|
|
||||||
#[cfg(feature = "msgpack")]
|
#[cfg(feature = "msgpack")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(msgpack::route::MSGPACK, post(msgpack::extract_msgpack))
|
.route(msgpack::route::MSGPACK, post(msgpack::extract_msgpack))
|
||||||
.route(
|
.route(
|
||||||
msgpack::route::MSGPACK_RAW,
|
msgpack::route::MSGPACK_RAW,
|
||||||
@@ -140,13 +140,13 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "xml")]
|
#[cfg(feature = "xml")]
|
||||||
let router = router.route(xml::route::XML, post(xml::extract_xml));
|
let router = router.route(xml::route::XML, post(xml::extract_xml));
|
||||||
|
|
||||||
#[cfg(feature = "toml")]
|
#[cfg(feature = "toml")]
|
||||||
let router = router.route(toml::route::TOML, post(toml::extract_toml));
|
let router = router.route(toml::route::TOML, post(toml::extract_toml));
|
||||||
|
|
||||||
#[cfg(feature = "sonic")]
|
#[cfg(feature = "sonic")]
|
||||||
let router = router.route(sonic::route::SONIC, post(sonic::extract_sonic));
|
let router = router.route(sonic::route::SONIC, post(sonic::extract_sonic));
|
||||||
|
|
||||||
let router = router.with_state(MyState::default());
|
let router = router.with_state(MyState::default());
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
extra_typed_path_type_name,
|
extra_typed_path_type_name,
|
||||||
invalid_extra_typed_path_response,
|
invalid_extra_typed_path_response,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
println!("All {} tests passed.", extra_typed_path_type_name);
|
println!("All {} tests passed.", extra_typed_path_type_name);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -562,9 +562,9 @@ mod typed_header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
I: Iterator<Item=&'i HeaderValue>,
|
I: Iterator<Item = &'i HeaderValue>,
|
||||||
{
|
{
|
||||||
let value = values.next().ok_or_else(Error::invalid)?;
|
let value = values.next().ok_or_else(Error::invalid)?;
|
||||||
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
||||||
@@ -683,8 +683,8 @@ mod extra {
|
|||||||
// 1.3. Implement your extractor (`FromRequestParts` or `FromRequest`)
|
// 1.3. Implement your extractor (`FromRequestParts` or `FromRequest`)
|
||||||
#[axum::async_trait]
|
#[axum::async_trait]
|
||||||
impl<S> FromRequestParts<S> for ParametersGarde
|
impl<S> FromRequestParts<S> for ParametersGarde
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
{
|
{
|
||||||
type Rejection = ParametersRejection;
|
type Rejection = ParametersRejection;
|
||||||
|
|
||||||
@@ -964,7 +964,9 @@ mod sonic {
|
|||||||
pub const SONIC: &str = "/sonic";
|
pub const SONIC: &str = "/sonic";
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn extract_sonic(Garde(Sonic(parameters)): Garde<Sonic<ParametersGarde>>) -> StatusCode {
|
pub async fn extract_sonic(
|
||||||
|
Garde(Sonic(parameters)): Garde<Sonic<ParametersGarde>>,
|
||||||
|
) -> StatusCode {
|
||||||
validate_again(parameters, ())
|
validate_again(parameters, ())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ pub mod validify;
|
|||||||
#[cfg(feature = "yaml")]
|
#[cfg(feature = "yaml")]
|
||||||
pub mod yaml;
|
pub mod yaml;
|
||||||
|
|
||||||
|
mod sonic;
|
||||||
#[cfg(feature = "toml")]
|
#[cfg(feature = "toml")]
|
||||||
pub mod toml;
|
pub mod toml;
|
||||||
#[cfg(feature = "typed_multipart")]
|
#[cfg(feature = "typed_multipart")]
|
||||||
pub mod typed_multipart;
|
pub mod typed_multipart;
|
||||||
#[cfg(feature = "xml")]
|
#[cfg(feature = "xml")]
|
||||||
pub mod xml;
|
pub mod xml;
|
||||||
mod sonic;
|
|
||||||
|
|
||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use axum::response::{IntoResponse, Response};
|
use axum::response::{IntoResponse, Response};
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ use validator::{Validate, ValidateArgs, ValidationError};
|
|||||||
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "typed_multipart",
|
feature = "typed_multipart",
|
||||||
derive(axum_typed_multipart::TryFromMultipart)
|
derive(axum_typed_multipart::TryFromMultipart)
|
||||||
)]
|
)]
|
||||||
pub struct Parameters {
|
pub struct Parameters {
|
||||||
#[validate(range(min = 5, max = 10))]
|
#[validate(range(min = 5, max = 10))]
|
||||||
@@ -34,8 +34,8 @@ pub struct Parameters {
|
|||||||
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
#[derive(Clone, Deserialize, Serialize, Validate, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
#[cfg_attr(feature = "extra_protobuf", derive(prost::Message))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "typed_multipart",
|
feature = "typed_multipart",
|
||||||
derive(axum_typed_multipart::TryFromMultipart)
|
derive(axum_typed_multipart::TryFromMultipart)
|
||||||
)]
|
)]
|
||||||
pub struct ParametersEx {
|
pub struct ParametersEx {
|
||||||
#[validate(custom(function = "validate_v0", arg = "&'v_a RangeInclusive<i32>"))]
|
#[validate(custom(function = "validate_v0", arg = "&'v_a RangeInclusive<i32>"))]
|
||||||
@@ -155,7 +155,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
.route(route::JSON_EX, post(extract_json_ex));
|
.route(route::JSON_EX, post(extract_json_ex));
|
||||||
|
|
||||||
#[cfg(feature = "typed_header")]
|
#[cfg(feature = "typed_header")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
typed_header::route::TYPED_HEADER,
|
typed_header::route::TYPED_HEADER,
|
||||||
post(typed_header::extract_typed_header),
|
post(typed_header::extract_typed_header),
|
||||||
@@ -166,7 +166,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "typed_multipart")]
|
#[cfg(feature = "typed_multipart")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
typed_multipart::route::TYPED_MULTIPART,
|
typed_multipart::route::TYPED_MULTIPART,
|
||||||
post(typed_multipart::extract_typed_multipart),
|
post(typed_multipart::extract_typed_multipart),
|
||||||
@@ -185,7 +185,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra")]
|
#[cfg(feature = "extra")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(extra::route::CACHED, post(extra::extract_cached))
|
.route(extra::route::CACHED, post(extra::extract_cached))
|
||||||
.route(extra::route::CACHED_EX, post(extra::extract_cached_ex))
|
.route(extra::route::CACHED_EX, post(extra::extract_cached_ex))
|
||||||
.route(
|
.route(
|
||||||
@@ -206,7 +206,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_typed_path")]
|
#[cfg(feature = "extra_typed_path")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
extra_typed_path::route::EXTRA_TYPED_PATH,
|
extra_typed_path::route::EXTRA_TYPED_PATH,
|
||||||
get(extra_typed_path::extract_extra_typed_path),
|
get(extra_typed_path::extract_extra_typed_path),
|
||||||
@@ -217,7 +217,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_query")]
|
#[cfg(feature = "extra_query")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
extra_query::route::EXTRA_QUERY,
|
extra_query::route::EXTRA_QUERY,
|
||||||
post(extra_query::extract_extra_query),
|
post(extra_query::extract_extra_query),
|
||||||
@@ -228,7 +228,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_form")]
|
#[cfg(feature = "extra_form")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
extra_form::route::EXTRA_FORM,
|
extra_form::route::EXTRA_FORM,
|
||||||
post(extra_form::extract_extra_form),
|
post(extra_form::extract_extra_form),
|
||||||
@@ -239,7 +239,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_protobuf")]
|
#[cfg(feature = "extra_protobuf")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
extra_protobuf::route::EXTRA_PROTOBUF,
|
extra_protobuf::route::EXTRA_PROTOBUF,
|
||||||
post(extra_protobuf::extract_extra_protobuf),
|
post(extra_protobuf::extract_extra_protobuf),
|
||||||
@@ -250,12 +250,12 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "yaml")]
|
#[cfg(feature = "yaml")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(yaml::route::YAML, post(yaml::extract_yaml))
|
.route(yaml::route::YAML, post(yaml::extract_yaml))
|
||||||
.route(yaml::route::YAML_EX, post(yaml::extract_yaml_ex));
|
.route(yaml::route::YAML_EX, post(yaml::extract_yaml_ex));
|
||||||
|
|
||||||
#[cfg(feature = "msgpack")]
|
#[cfg(feature = "msgpack")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(msgpack::route::MSGPACK, post(msgpack::extract_msgpack))
|
.route(msgpack::route::MSGPACK, post(msgpack::extract_msgpack))
|
||||||
.route(
|
.route(
|
||||||
msgpack::route::MSGPACK_EX,
|
msgpack::route::MSGPACK_EX,
|
||||||
@@ -271,17 +271,17 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "xml")]
|
#[cfg(feature = "xml")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(xml::route::XML, post(xml::extract_xml))
|
.route(xml::route::XML, post(xml::extract_xml))
|
||||||
.route(xml::route::XML_EX, post(xml::extract_xml_ex));
|
.route(xml::route::XML_EX, post(xml::extract_xml_ex));
|
||||||
|
|
||||||
#[cfg(feature = "toml")]
|
#[cfg(feature = "toml")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(toml::route::TOML, post(toml::extract_toml))
|
.route(toml::route::TOML, post(toml::extract_toml))
|
||||||
.route(toml::route::TOML_EX, post(toml::extract_toml_ex));
|
.route(toml::route::TOML_EX, post(toml::extract_toml_ex));
|
||||||
|
|
||||||
#[cfg(feature = "sonic")]
|
#[cfg(feature = "sonic")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(sonic::route::SONIC, post(sonic::extract_sonic))
|
.route(sonic::route::SONIC, post(sonic::extract_sonic))
|
||||||
.route(sonic::route::SONIC_EX, post(sonic::extract_sonic_ex));
|
.route(sonic::route::SONIC_EX, post(sonic::extract_sonic_ex));
|
||||||
|
|
||||||
@@ -528,7 +528,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
extra_typed_path_type_name,
|
extra_typed_path_type_name,
|
||||||
invalid_extra_typed_path_response,
|
invalid_extra_typed_path_response,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
println!("All {} tests passed.", extra_typed_path_type_name);
|
println!("All {} tests passed.", extra_typed_path_type_name);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -826,9 +826,9 @@ mod typed_header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
I: Iterator<Item=&'i HeaderValue>,
|
I: Iterator<Item = &'i HeaderValue>,
|
||||||
{
|
{
|
||||||
let value = values.next().ok_or_else(Error::invalid)?;
|
let value = values.next().ok_or_else(Error::invalid)?;
|
||||||
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
||||||
@@ -859,9 +859,9 @@ mod typed_header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
I: Iterator<Item=&'i HeaderValue>,
|
I: Iterator<Item = &'i HeaderValue>,
|
||||||
{
|
{
|
||||||
let value = values.next().ok_or_else(Error::invalid)?;
|
let value = values.next().ok_or_else(Error::invalid)?;
|
||||||
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
||||||
@@ -1007,8 +1007,8 @@ mod extra {
|
|||||||
// 1.3. Implement your extractor (`FromRequestParts` or `FromRequest`)
|
// 1.3. Implement your extractor (`FromRequestParts` or `FromRequest`)
|
||||||
#[axum::async_trait]
|
#[axum::async_trait]
|
||||||
impl<S> FromRequestParts<S> for Parameters
|
impl<S> FromRequestParts<S> for Parameters
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
{
|
{
|
||||||
type Rejection = ParametersRejection;
|
type Rejection = ParametersRejection;
|
||||||
|
|
||||||
@@ -1023,8 +1023,8 @@ mod extra {
|
|||||||
|
|
||||||
#[axum::async_trait]
|
#[axum::async_trait]
|
||||||
impl<S> FromRequestParts<S> for ParametersEx
|
impl<S> FromRequestParts<S> for ParametersEx
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
{
|
{
|
||||||
type Rejection = ParametersRejection;
|
type Rejection = ParametersRejection;
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ pub struct ParametersValidify {
|
|||||||
#[derive(Clone, Validify, Eq, PartialEq)]
|
#[derive(Clone, Validify, Eq, PartialEq)]
|
||||||
#[cfg_attr(feature = "extra_protobuf", derive(Message))]
|
#[cfg_attr(feature = "extra_protobuf", derive(Message))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "typed_multipart",
|
feature = "typed_multipart",
|
||||||
derive(axum_typed_multipart::TryFromMultipart)
|
derive(axum_typed_multipart::TryFromMultipart)
|
||||||
)]
|
)]
|
||||||
pub struct ParametersValidifyWithoutPayload {
|
pub struct ParametersValidifyWithoutPayload {
|
||||||
#[validate(range(min = 5.0, max = 10.0))]
|
#[validate(range(min = 5.0, max = 10.0))]
|
||||||
@@ -145,7 +145,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "typed_header")]
|
#[cfg(feature = "typed_header")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
typed_header::route::TYPED_HEADER,
|
typed_header::route::TYPED_HEADER,
|
||||||
post(typed_header::extract_typed_header),
|
post(typed_header::extract_typed_header),
|
||||||
@@ -160,7 +160,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "typed_multipart")]
|
#[cfg(feature = "typed_multipart")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
typed_multipart::route::TYPED_MULTIPART,
|
typed_multipart::route::TYPED_MULTIPART,
|
||||||
post(typed_multipart::extract_typed_multipart),
|
post(typed_multipart::extract_typed_multipart),
|
||||||
@@ -187,7 +187,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra")]
|
#[cfg(feature = "extra")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(extra::route::CACHED, post(extra::extract_cached))
|
.route(extra::route::CACHED, post(extra::extract_cached))
|
||||||
.route(
|
.route(
|
||||||
extra::route::CACHED_MODIFIED,
|
extra::route::CACHED_MODIFIED,
|
||||||
@@ -223,7 +223,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_typed_path")]
|
#[cfg(feature = "extra_typed_path")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
extra_typed_path::route::EXTRA_TYPED_PATH,
|
extra_typed_path::route::EXTRA_TYPED_PATH,
|
||||||
get(extra_typed_path::extract_extra_typed_path),
|
get(extra_typed_path::extract_extra_typed_path),
|
||||||
@@ -238,7 +238,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_query")]
|
#[cfg(feature = "extra_query")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
extra_query::route::EXTRA_QUERY,
|
extra_query::route::EXTRA_QUERY,
|
||||||
post(extra_query::extract_extra_query),
|
post(extra_query::extract_extra_query),
|
||||||
@@ -257,7 +257,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_form")]
|
#[cfg(feature = "extra_form")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
extra_form::route::EXTRA_FORM,
|
extra_form::route::EXTRA_FORM,
|
||||||
post(extra_form::extract_extra_form),
|
post(extra_form::extract_extra_form),
|
||||||
@@ -276,7 +276,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "extra_protobuf")]
|
#[cfg(feature = "extra_protobuf")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(
|
.route(
|
||||||
extra_protobuf::route::EXTRA_PROTOBUF,
|
extra_protobuf::route::EXTRA_PROTOBUF,
|
||||||
post(extra_protobuf::extract_extra_protobuf),
|
post(extra_protobuf::extract_extra_protobuf),
|
||||||
@@ -291,7 +291,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "yaml")]
|
#[cfg(feature = "yaml")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(yaml::route::YAML, post(yaml::extract_yaml))
|
.route(yaml::route::YAML, post(yaml::extract_yaml))
|
||||||
.route(
|
.route(
|
||||||
yaml::route::YAML_MODIFIED,
|
yaml::route::YAML_MODIFIED,
|
||||||
@@ -307,7 +307,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "msgpack")]
|
#[cfg(feature = "msgpack")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(msgpack::route::MSGPACK, post(msgpack::extract_msgpack))
|
.route(msgpack::route::MSGPACK, post(msgpack::extract_msgpack))
|
||||||
.route(
|
.route(
|
||||||
msgpack::route::MSGPACK_MODIFIED,
|
msgpack::route::MSGPACK_MODIFIED,
|
||||||
@@ -339,7 +339,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "xml")]
|
#[cfg(feature = "xml")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(xml::route::XML, post(xml::extract_xml))
|
.route(xml::route::XML, post(xml::extract_xml))
|
||||||
.route(xml::route::XML_MODIFIED, post(xml::extract_xml_modified))
|
.route(xml::route::XML_MODIFIED, post(xml::extract_xml_modified))
|
||||||
.route(
|
.route(
|
||||||
@@ -352,7 +352,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "toml")]
|
#[cfg(feature = "toml")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(toml::route::TOML, post(toml::extract_toml))
|
.route(toml::route::TOML, post(toml::extract_toml))
|
||||||
.route(
|
.route(
|
||||||
toml::route::TOML_MODIFIED,
|
toml::route::TOML_MODIFIED,
|
||||||
@@ -368,7 +368,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(feature = "sonic")]
|
#[cfg(feature = "sonic")]
|
||||||
let router = router
|
let router = router
|
||||||
.route(sonic::route::SONIC, post(sonic::extract_sonic))
|
.route(sonic::route::SONIC, post(sonic::extract_sonic))
|
||||||
.route(
|
.route(
|
||||||
sonic::route::SONIC_MODIFIED,
|
sonic::route::SONIC_MODIFIED,
|
||||||
@@ -409,7 +409,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
VALIDATION_ERROR_STATUS,
|
VALIDATION_ERROR_STATUS,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn test_extra_path_modified(
|
async fn test_extra_path_modified(
|
||||||
@@ -426,7 +426,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
StatusCode::OK,
|
StatusCode::OK,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn test_extra_path_validified(
|
async fn test_extra_path_validified(
|
||||||
@@ -443,7 +443,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
VALIDATION_ERROR_STATUS,
|
VALIDATION_ERROR_STATUS,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn do_test_extra_path(
|
async fn do_test_extra_path(
|
||||||
@@ -726,7 +726,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
VALIDATION_ERROR_STATUS,
|
VALIDATION_ERROR_STATUS,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn test_extra_typed_path_modified(
|
async fn test_extra_typed_path_modified(
|
||||||
@@ -743,7 +743,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
StatusCode::OK,
|
StatusCode::OK,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn do_test_extra_typed_path(
|
async fn do_test_extra_typed_path(
|
||||||
@@ -804,7 +804,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
extra_typed_path_type_name,
|
extra_typed_path_type_name,
|
||||||
invalid_extra_typed_path_response,
|
invalid_extra_typed_path_response,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
println!("All {} tests passed.", extra_typed_path_type_name);
|
println!("All {} tests passed.", extra_typed_path_type_name);
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -818,7 +818,7 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
"extra_typed_path_validified_by_ref",
|
"extra_typed_path_validified_by_ref",
|
||||||
&server_url,
|
&server_url,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "extra_query")]
|
#[cfg(feature = "extra_query")]
|
||||||
@@ -1045,7 +1045,10 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
.await?;
|
.await?;
|
||||||
// Modified
|
// Modified
|
||||||
test_executor
|
test_executor
|
||||||
.execute_modified::<Sonic<ParametersValidify>>(Method::POST, sonic::route::SONIC_MODIFIED)
|
.execute_modified::<Sonic<ParametersValidify>>(
|
||||||
|
Method::POST,
|
||||||
|
sonic::route::SONIC_MODIFIED,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
// Validified
|
// Validified
|
||||||
test_executor
|
test_executor
|
||||||
@@ -1056,7 +1059,10 @@ async fn test_main() -> anyhow::Result<()> {
|
|||||||
.await?;
|
.await?;
|
||||||
// ValidifiedByRef
|
// ValidifiedByRef
|
||||||
test_executor
|
test_executor
|
||||||
.execute::<Sonic<ParametersValidify>>(Method::POST, sonic::route::SONIC_VALIDIFIED_BY_REF)
|
.execute::<Sonic<ParametersValidify>>(
|
||||||
|
Method::POST,
|
||||||
|
sonic::route::SONIC_VALIDIFIED_BY_REF,
|
||||||
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1089,7 +1095,7 @@ impl TestExecutor {
|
|||||||
T::INVALID_STATUS_CODE,
|
T::INVALID_STATUS_CODE,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute all tests for `Modified` without validation
|
/// Execute all tests for `Modified` without validation
|
||||||
@@ -1106,7 +1112,7 @@ impl TestExecutor {
|
|||||||
StatusCode::OK,
|
StatusCode::OK,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute all tests for `Modified` without validation
|
/// Execute all tests for `Modified` without validation
|
||||||
@@ -1123,7 +1129,7 @@ impl TestExecutor {
|
|||||||
T::INVALID_STATUS_CODE,
|
T::INVALID_STATUS_CODE,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn do_execute<T: ValidTest>(
|
async fn do_execute<T: ValidTest>(
|
||||||
@@ -1387,9 +1393,9 @@ mod typed_header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
fn decode<'i, I>(values: &mut I) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
I: Iterator<Item=&'i HeaderValue>,
|
I: Iterator<Item = &'i HeaderValue>,
|
||||||
{
|
{
|
||||||
let value = values.next().ok_or_else(Error::invalid)?;
|
let value = values.next().ok_or_else(Error::invalid)?;
|
||||||
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
let src = std::str::from_utf8(value.as_bytes()).map_err(|_| Error::invalid())?;
|
||||||
@@ -1557,8 +1563,8 @@ mod extra {
|
|||||||
// 1.3. Implement your extractor (`FromRequestParts` or `FromRequest`)
|
// 1.3. Implement your extractor (`FromRequestParts` or `FromRequest`)
|
||||||
#[axum::async_trait]
|
#[axum::async_trait]
|
||||||
impl<S> FromRequestParts<S> for ParametersValidify
|
impl<S> FromRequestParts<S> for ParametersValidify
|
||||||
where
|
where
|
||||||
S: Send + Sync,
|
S: Send + Sync,
|
||||||
{
|
{
|
||||||
type Rejection = ParametersRejection;
|
type Rejection = ParametersRejection;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user