diff --git a/axum/src/extract/matched_path.rs b/axum/src/extract/matched_path.rs index 8cef754f..ae7d130d 100644 --- a/axum/src/extract/matched_path.rs +++ b/axum/src/extract/matched_path.rs @@ -168,14 +168,14 @@ fn append_nested_matched_path(matched_path: &Arc, extensions: &http::Extens mod tests { use super::*; use crate::{ - body::Body, + extract::Request, handler::HandlerWithoutStateExt, middleware::map_request, routing::{any, get}, test_helpers::*, Router, }; - use http::{Request, StatusCode}; + use http::StatusCode; #[crate::test] async fn extracting_on_handler() { @@ -361,7 +361,7 @@ mod tests { let app = Router::new().route( "/*path", - any(|req: Request| { + any(|req: Request| { Router::new() .nest("/", Router::new().route("/foo", get(|| async {}))) .oneshot(req) @@ -376,7 +376,7 @@ mod tests { #[crate::test] async fn cant_extract_in_fallback() { - async fn handler(path: Option, req: Request) { + async fn handler(path: Option, req: Request) { assert!(path.is_none()); assert!(req.extensions().get::().is_none()); } diff --git a/axum/src/extract/multipart.rs b/axum/src/extract/multipart.rs index c8478d09..9d1518c8 100644 --- a/axum/src/extract/multipart.rs +++ b/axum/src/extract/multipart.rs @@ -7,8 +7,8 @@ use crate::body::Bytes; use async_trait::async_trait; use axum_core::__composite_rejection as composite_rejection; use axum_core::__define_rejection as define_rejection; -use axum_core::response::{IntoResponse, Response}; use axum_core::body::Body; +use axum_core::response::{IntoResponse, Response}; use axum_core::RequestExt; use futures_util::stream::Stream; use http::header::{HeaderMap, CONTENT_TYPE}; diff --git a/axum/src/routing/mod.rs b/axum/src/routing/mod.rs index 8a940a4d..12b66ac6 100644 --- a/axum/src/routing/mod.rs +++ b/axum/src/routing/mod.rs @@ -16,7 +16,8 @@ use axum_core::{ use std::{ convert::Infallible, fmt, - task::{Context, Poll}, marker::PhantomData, + marker::PhantomData, + task::{Context, Poll}, }; use sync_wrapper::SyncWrapper; use tower_layer::Layer; @@ -627,10 +628,10 @@ where fn layer(self, layer: L) -> Endpoint where L: Layer + Clone + Send + 'static, - L::Service: Service> + Clone + Send + 'static, - >>::Response: IntoResponse + 'static, - >>::Error: Into + 'static, - >>::Future: Send + 'static, + L::Service: Service + Clone + Send + 'static, + >::Response: IntoResponse + 'static, + >::Error: Into + 'static, + >::Future: Send + 'static, { match self { Endpoint::MethodRouter(method_router) => { diff --git a/axum/src/routing/path_router.rs b/axum/src/routing/path_router.rs index 91d13458..6baa7943 100644 --- a/axum/src/routing/path_router.rs +++ b/axum/src/routing/path_router.rs @@ -1,6 +1,5 @@ -use crate::body::Body; +use crate::extract::Request; use axum_core::response::IntoResponse; -use http::Request; use matchit::MatchError; use std::{borrow::Cow, collections::HashMap, convert::Infallible, fmt, sync::Arc}; use tower_layer::Layer; @@ -71,7 +70,7 @@ where service: T, ) -> Result<(), Cow<'static, str>> where - T: Service, Error = Infallible> + Clone + Send + 'static, + T: Service + Clone + Send + 'static, T::Response: IntoResponse, T::Future: Send + 'static, { @@ -166,7 +165,7 @@ where pub(super) fn nest_service(&mut self, path: &str, svc: T) -> Result<(), Cow<'static, str>> where - T: Service, Error = Infallible> + Clone + Send + 'static, + T: Service + Clone + Send + 'static, T::Response: IntoResponse, T::Future: Send + 'static, { @@ -198,10 +197,10 @@ where pub(super) fn layer(self, layer: L) -> PathRouter where L: Layer + Clone + Send + 'static, - L::Service: Service> + Clone + Send + 'static, - >>::Response: IntoResponse + 'static, - >>::Error: Into + 'static, - >>::Future: Send + 'static, + L::Service: Service + Clone + Send + 'static, + >::Response: IntoResponse + 'static, + >::Error: Into + 'static, + >::Future: Send + 'static, { let routes = self .routes @@ -223,10 +222,10 @@ where pub(super) fn route_layer(self, layer: L) -> Self where L: Layer + Clone + Send + 'static, - L::Service: Service> + Clone + Send + 'static, - >>::Response: IntoResponse + 'static, - >>::Error: Into + 'static, - >>::Future: Send + 'static, + L::Service: Service + Clone + Send + 'static, + >::Response: IntoResponse + 'static, + >::Error: Into + 'static, + >::Future: Send + 'static, { if self.routes.is_empty() { panic!( @@ -275,9 +274,9 @@ where pub(super) fn call_with_state( &mut self, - mut req: Request, + mut req: Request, state: S, - ) -> Result, (Request, S)> { + ) -> Result, (Request, S)> { #[cfg(feature = "original-uri")] { use crate::extract::OriginalUri; diff --git a/axum/src/routing/tests/mod.rs b/axum/src/routing/tests/mod.rs index c3f7875d..40585eed 100644 --- a/axum/src/routing/tests/mod.rs +++ b/axum/src/routing/tests/mod.rs @@ -4,13 +4,20 @@ use crate::{ extract::{self, DefaultBodyLimit, FromRef, Path, State}, handler::{Handler, HandlerWithoutStateExt}, response::{IntoResponse, Response}, - routing::{delete, get, get_service, on, on_service, patch, patch_service, post, MethodFilter, path_router::path_for_nested_route}, - test_helpers::{*, tracing_helpers::{capture_tracing, TracingEvent}}, - BoxError, Json, Router, Extension, + routing::{ + delete, get, get_service, on, on_service, patch, patch_service, + path_router::path_for_nested_route, post, MethodFilter, + }, + test_helpers::{ + tracing_helpers::{capture_tracing, TracingEvent}, + *, + }, + BoxError, Extension, Json, Router, }; use axum_core::extract::Request; use futures_util::stream::StreamExt; use http::{header::ALLOW, header::CONTENT_LENGTH, HeaderMap, StatusCode, Uri}; +use serde::Deserialize; use serde_json::json; use std::{ convert::Infallible, @@ -22,7 +29,6 @@ use std::{ use tower::{service_fn, timeout::TimeoutLayer, util::MapResponseLayer, ServiceBuilder}; use tower_http::{limit::RequestBodyLimitLayer, validate_request::ValidateRequestHeaderLayer}; use tower_service::Service; -use serde::Deserialize; mod fallback; mod get_to_head;