mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-28 00:00:20 +02:00
Relax bounds for FromExtractor (#1469)
Fixes #1467 We didn't actually use the bounds. I guess they were left over from a previous version.
This commit is contained in:
@@ -201,7 +201,7 @@ where
|
|||||||
impl<T, E, B, S> Service<Request<B>> for FromExtractor<T, E, S>
|
impl<T, E, B, S> Service<Request<B>> for FromExtractor<T, E, S>
|
||||||
where
|
where
|
||||||
E: FromRequestParts<S> + 'static,
|
E: FromRequestParts<S> + 'static,
|
||||||
B: Default + Send + 'static,
|
B: Send + 'static,
|
||||||
T: Service<Request<B>> + Clone,
|
T: Service<Request<B>> + Clone,
|
||||||
T::Response: IntoResponse,
|
T::Response: IntoResponse,
|
||||||
S: Clone + Send + Sync + 'static,
|
S: Clone + Send + Sync + 'static,
|
||||||
@@ -266,7 +266,6 @@ where
|
|||||||
E: FromRequestParts<S>,
|
E: FromRequestParts<S>,
|
||||||
T: Service<Request<B>>,
|
T: Service<Request<B>>,
|
||||||
T::Response: IntoResponse,
|
T::Response: IntoResponse,
|
||||||
B: Default,
|
|
||||||
{
|
{
|
||||||
type Output = Result<Response, T::Error>;
|
type Output = Result<Response, T::Error>;
|
||||||
|
|
||||||
@@ -305,9 +304,10 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{handler::Handler, routing::get, test_helpers::*, Router};
|
use crate::{async_trait, handler::Handler, routing::get, test_helpers::*, Router};
|
||||||
use axum_core::extract::FromRef;
|
use axum_core::extract::FromRef;
|
||||||
use http::{header, request::Parts, StatusCode};
|
use http::{header, request::Parts, StatusCode};
|
||||||
|
use tower_http::limit::RequestBodyLimitLayer;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_from_extractor() {
|
async fn test_from_extractor() {
|
||||||
@@ -363,4 +363,29 @@ mod tests {
|
|||||||
.await;
|
.await;
|
||||||
assert_eq!(res.status(), StatusCode::OK);
|
assert_eq!(res.status(), StatusCode::OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// just needs to compile
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn works_with_request_body_limit() {
|
||||||
|
struct MyExtractor;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl<S> FromRequestParts<S> for MyExtractor
|
||||||
|
where
|
||||||
|
S: Send + Sync,
|
||||||
|
{
|
||||||
|
type Rejection = std::convert::Infallible;
|
||||||
|
|
||||||
|
async fn from_request_parts(
|
||||||
|
_parts: &mut Parts,
|
||||||
|
_state: &S,
|
||||||
|
) -> Result<Self, Self::Rejection> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let _: Router = Router::new()
|
||||||
|
.layer(from_extractor::<MyExtractor>())
|
||||||
|
.layer(RequestBodyLimitLayer::new(1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user