mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-19 00:00:14 +02:00
Replace RoutingDsl trait with Router type (#214)
* Remove `RoutingDsl` * Fix typo
This commit is contained in:
+10
-10
@@ -1,8 +1,8 @@
|
||||
//! Extractor for getting connection information from a client.
|
||||
//!
|
||||
//! See [`RoutingDsl::into_make_service_with_connect_info`] for more details.
|
||||
//! See [`Router::into_make_service_with_connect_info`] for more details.
|
||||
//!
|
||||
//! [`RoutingDsl::into_make_service_with_connect_info`]: crate::routing::RoutingDsl::into_make_service_with_connect_info
|
||||
//! [`Router::into_make_service_with_connect_info`]: crate::routing::Router::into_make_service_with_connect_info
|
||||
|
||||
use super::{Extension, FromRequest, RequestParts};
|
||||
use async_trait::async_trait;
|
||||
@@ -19,10 +19,10 @@ use tower_http::add_extension::AddExtension;
|
||||
|
||||
/// A [`MakeService`] created from a router.
|
||||
///
|
||||
/// See [`RoutingDsl::into_make_service_with_connect_info`] for more details.
|
||||
/// See [`Router::into_make_service_with_connect_info`] for more details.
|
||||
///
|
||||
/// [`MakeService`]: tower::make::MakeService
|
||||
/// [`RoutingDsl::into_make_service_with_connect_info`]: crate::routing::RoutingDsl::into_make_service_with_connect_info
|
||||
/// [`Router::into_make_service_with_connect_info`]: crate::routing::Router::into_make_service_with_connect_info
|
||||
pub struct IntoMakeServiceWithConnectInfo<S, C> {
|
||||
svc: S,
|
||||
_connect_info: PhantomData<fn() -> C>,
|
||||
@@ -54,9 +54,9 @@ where
|
||||
/// The goal for this trait is to allow users to implement custom IO types that
|
||||
/// can still provide the same connection metadata.
|
||||
///
|
||||
/// See [`RoutingDsl::into_make_service_with_connect_info`] for more details.
|
||||
/// See [`Router::into_make_service_with_connect_info`] for more details.
|
||||
///
|
||||
/// [`RoutingDsl::into_make_service_with_connect_info`]: crate::routing::RoutingDsl::into_make_service_with_connect_info
|
||||
/// [`Router::into_make_service_with_connect_info`]: crate::routing::Router::into_make_service_with_connect_info
|
||||
pub trait Connected<T> {
|
||||
/// The connection information type the IO resources generates.
|
||||
type ConnectInfo: Clone + Send + Sync + 'static;
|
||||
@@ -104,12 +104,12 @@ opaque_future! {
|
||||
/// Extractor for getting connection information produced by a [`Connected`].
|
||||
///
|
||||
/// Note this extractor requires you to use
|
||||
/// [`RoutingDsl::into_make_service_with_connect_info`] to run your app
|
||||
/// [`Router::into_make_service_with_connect_info`] to run your app
|
||||
/// otherwise it will fail at runtime.
|
||||
///
|
||||
/// See [`RoutingDsl::into_make_service_with_connect_info`] for more details.
|
||||
/// See [`Router::into_make_service_with_connect_info`] for more details.
|
||||
///
|
||||
/// [`RoutingDsl::into_make_service_with_connect_info`]: crate::routing::RoutingDsl::into_make_service_with_connect_info
|
||||
/// [`Router::into_make_service_with_connect_info`]: crate::routing::Router::into_make_service_with_connect_info
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct ConnectInfo<T>(pub T);
|
||||
|
||||
@@ -131,7 +131,7 @@ where
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::Server;
|
||||
use crate::{handler::get, route, routing::RoutingDsl};
|
||||
use crate::{handler::get, route};
|
||||
use std::net::{SocketAddr, TcpListener};
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -13,7 +13,6 @@ use std::ops::Deref;
|
||||
/// extract::ContentLengthLimit,
|
||||
/// handler::post,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
///
|
||||
/// async fn handler(body: ContentLengthLimit<String, 1024>) {
|
||||
|
||||
@@ -14,7 +14,6 @@ use std::ops::Deref;
|
||||
/// extract::Extension,
|
||||
/// handler::get,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
|
||||
@@ -38,7 +38,6 @@ use tower::{BoxError, Layer, Service};
|
||||
/// extract::{extractor_middleware, FromRequest, RequestParts},
|
||||
/// handler::{get, post},
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
/// use http::StatusCode;
|
||||
/// use async_trait::async_trait;
|
||||
|
||||
@@ -18,7 +18,6 @@ use tower::BoxError;
|
||||
/// extract::Form,
|
||||
/// handler::post,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
/// use serde::Deserialize;
|
||||
///
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
//! Json,
|
||||
//! handler::{post, Handler},
|
||||
//! route,
|
||||
//! routing::RoutingDsl
|
||||
//! };
|
||||
//! use serde::Deserialize;
|
||||
//!
|
||||
@@ -44,7 +43,6 @@
|
||||
//! extract::{FromRequest, RequestParts},
|
||||
//! handler::get,
|
||||
//! route,
|
||||
//! routing::RoutingDsl
|
||||
//! };
|
||||
//! use http::{StatusCode, header::{HeaderValue, USER_AGENT}};
|
||||
//!
|
||||
@@ -89,7 +87,6 @@
|
||||
//! extract::{Path, Query},
|
||||
//! handler::get,
|
||||
//! route,
|
||||
//! routing::RoutingDsl
|
||||
//! };
|
||||
//! use std::collections::HashMap;
|
||||
//!
|
||||
@@ -122,7 +119,6 @@
|
||||
//! extract::Json,
|
||||
//! handler::post,
|
||||
//! route,
|
||||
//! routing::RoutingDsl
|
||||
//! };
|
||||
//! use serde_json::Value;
|
||||
//!
|
||||
@@ -148,7 +144,6 @@
|
||||
//! extract::{Json, rejection::JsonRejection},
|
||||
//! handler::post,
|
||||
//! route,
|
||||
//! routing::RoutingDsl
|
||||
//! };
|
||||
//! use serde_json::Value;
|
||||
//!
|
||||
@@ -190,7 +185,6 @@
|
||||
//! extract::Json,
|
||||
//! handler::post,
|
||||
//! route,
|
||||
//! routing::RoutingDsl
|
||||
//! };
|
||||
//! use serde_json::Value;
|
||||
//!
|
||||
@@ -224,7 +218,6 @@
|
||||
//! handler::get,
|
||||
//! http::{header::HeaderMap, Request},
|
||||
//! route,
|
||||
//! routing::RoutingDsl
|
||||
//! };
|
||||
//!
|
||||
//! struct MyBody<B>(B);
|
||||
|
||||
@@ -24,7 +24,6 @@ use tower::BoxError;
|
||||
/// extract::Multipart,
|
||||
/// handler::post,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
/// use futures::stream::StreamExt;
|
||||
///
|
||||
|
||||
@@ -15,7 +15,6 @@ use std::ops::{Deref, DerefMut};
|
||||
/// extract::Path,
|
||||
/// handler::get,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
/// use uuid::Uuid;
|
||||
///
|
||||
@@ -38,7 +37,6 @@ use std::ops::{Deref, DerefMut};
|
||||
/// extract::Path,
|
||||
/// handler::get,
|
||||
/// route,
|
||||
/// routing::RoutingDsl,
|
||||
/// };
|
||||
/// use uuid::Uuid;
|
||||
///
|
||||
@@ -60,7 +58,6 @@ use std::ops::{Deref, DerefMut};
|
||||
/// extract::Path,
|
||||
/// handler::get,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
/// use serde::Deserialize;
|
||||
/// use uuid::Uuid;
|
||||
|
||||
@@ -14,7 +14,6 @@ use std::ops::Deref;
|
||||
/// extract::Query,
|
||||
/// handler::get,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
/// use serde::Deserialize;
|
||||
///
|
||||
|
||||
@@ -11,7 +11,6 @@ use std::convert::Infallible;
|
||||
/// extract::RawQuery,
|
||||
/// handler::get,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
/// use futures::StreamExt;
|
||||
///
|
||||
|
||||
@@ -93,7 +93,7 @@ where
|
||||
/// use axum::{
|
||||
/// handler::get,
|
||||
/// route,
|
||||
/// routing::{nest, RoutingDsl},
|
||||
/// routing::nest,
|
||||
/// extract::OriginalUri,
|
||||
/// http::Uri
|
||||
/// };
|
||||
@@ -175,7 +175,6 @@ where
|
||||
/// extract::BodyStream,
|
||||
/// handler::get,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
/// use futures::StreamExt;
|
||||
///
|
||||
@@ -229,7 +228,6 @@ where
|
||||
/// extract::Body,
|
||||
/// handler::get,
|
||||
/// route,
|
||||
/// routing::RoutingDsl,
|
||||
/// };
|
||||
/// use futures::StreamExt;
|
||||
///
|
||||
|
||||
@@ -15,7 +15,6 @@ use std::{convert::Infallible, ops::Deref};
|
||||
/// extract::TypedHeader,
|
||||
/// handler::get,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
/// use headers::UserAgent;
|
||||
///
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
//! handler::get,
|
||||
//! response::IntoResponse,
|
||||
//! route,
|
||||
//! routing::RoutingDsl
|
||||
//! };
|
||||
//!
|
||||
//! let app = route("/ws", get(handler));
|
||||
@@ -115,7 +114,6 @@ impl WebSocketUpgrade {
|
||||
/// handler::get,
|
||||
/// response::IntoResponse,
|
||||
/// route,
|
||||
/// routing::RoutingDsl
|
||||
/// };
|
||||
///
|
||||
/// let app = route("/ws", get(handler));
|
||||
|
||||
Reference in New Issue
Block a user