mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-28 15:30:16 +01:00
Use Request
type alias in new files
This commit is contained in:
parent
877e3fe4de
commit
4d5035faf8
5 changed files with 34 additions and 28 deletions
|
@ -168,14 +168,14 @@ fn append_nested_matched_path(matched_path: &Arc<str>, 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<Body>| {
|
||||
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<MatchedPath>, req: Request<Body>) {
|
||||
async fn handler(path: Option<MatchedPath>, req: Request) {
|
||||
assert!(path.is_none());
|
||||
assert!(req.extensions().get::<MatchedPath>().is_none());
|
||||
}
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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<L>(self, layer: L) -> Endpoint<S>
|
||||
where
|
||||
L: Layer<Route> + Clone + Send + 'static,
|
||||
L::Service: Service<Request<Body>> + Clone + Send + 'static,
|
||||
<L::Service as Service<Request<Body>>>::Response: IntoResponse + 'static,
|
||||
<L::Service as Service<Request<Body>>>::Error: Into<Infallible> + 'static,
|
||||
<L::Service as Service<Request<Body>>>::Future: Send + 'static,
|
||||
L::Service: Service<Request> + Clone + Send + 'static,
|
||||
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
|
||||
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
|
||||
<L::Service as Service<Request>>::Future: Send + 'static,
|
||||
{
|
||||
match self {
|
||||
Endpoint::MethodRouter(method_router) => {
|
||||
|
|
|
@ -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<Request<Body>, Error = Infallible> + Clone + Send + 'static,
|
||||
T: Service<Request, Error = Infallible> + Clone + Send + 'static,
|
||||
T::Response: IntoResponse,
|
||||
T::Future: Send + 'static,
|
||||
{
|
||||
|
@ -166,7 +165,7 @@ where
|
|||
|
||||
pub(super) fn nest_service<T>(&mut self, path: &str, svc: T) -> Result<(), Cow<'static, str>>
|
||||
where
|
||||
T: Service<Request<Body>, Error = Infallible> + Clone + Send + 'static,
|
||||
T: Service<Request, Error = Infallible> + Clone + Send + 'static,
|
||||
T::Response: IntoResponse,
|
||||
T::Future: Send + 'static,
|
||||
{
|
||||
|
@ -198,10 +197,10 @@ where
|
|||
pub(super) fn layer<L>(self, layer: L) -> PathRouter<S, IS_FALLBACK>
|
||||
where
|
||||
L: Layer<Route> + Clone + Send + 'static,
|
||||
L::Service: Service<Request<Body>> + Clone + Send + 'static,
|
||||
<L::Service as Service<Request<Body>>>::Response: IntoResponse + 'static,
|
||||
<L::Service as Service<Request<Body>>>::Error: Into<Infallible> + 'static,
|
||||
<L::Service as Service<Request<Body>>>::Future: Send + 'static,
|
||||
L::Service: Service<Request> + Clone + Send + 'static,
|
||||
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
|
||||
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
|
||||
<L::Service as Service<Request>>::Future: Send + 'static,
|
||||
{
|
||||
let routes = self
|
||||
.routes
|
||||
|
@ -223,10 +222,10 @@ where
|
|||
pub(super) fn route_layer<L>(self, layer: L) -> Self
|
||||
where
|
||||
L: Layer<Route> + Clone + Send + 'static,
|
||||
L::Service: Service<Request<Body>> + Clone + Send + 'static,
|
||||
<L::Service as Service<Request<Body>>>::Response: IntoResponse + 'static,
|
||||
<L::Service as Service<Request<Body>>>::Error: Into<Infallible> + 'static,
|
||||
<L::Service as Service<Request<Body>>>::Future: Send + 'static,
|
||||
L::Service: Service<Request> + Clone + Send + 'static,
|
||||
<L::Service as Service<Request>>::Response: IntoResponse + 'static,
|
||||
<L::Service as Service<Request>>::Error: Into<Infallible> + 'static,
|
||||
<L::Service as Service<Request>>::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<Body>,
|
||||
mut req: Request,
|
||||
state: S,
|
||||
) -> Result<RouteFuture<Infallible>, (Request<Body>, S)> {
|
||||
) -> Result<RouteFuture<Infallible>, (Request, S)> {
|
||||
#[cfg(feature = "original-uri")]
|
||||
{
|
||||
use crate::extract::OriginalUri;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue