Export Or in a more consistent way

This commit is contained in:
David Pedersen
2021-08-19 22:44:26 +02:00
parent 570e13195c
commit 23dcf3631e
2 changed files with 8 additions and 5 deletions
+2
View File
@@ -14,6 +14,8 @@ use tower::{
BoxError, Service, BoxError, Service,
}; };
pub use super::or::ResponseFuture as OrResponseFuture;
opaque_future! { opaque_future! {
/// Response future for [`EmptyRouter`](super::EmptyRouter). /// Response future for [`EmptyRouter`](super::EmptyRouter).
pub type EmptyRouterFuture<E> = pub type EmptyRouterFuture<E> =
+6 -5
View File
@@ -29,9 +29,9 @@ use tower::{
use tower_http::map_response_body::MapResponseBodyLayer; use tower_http::map_response_body::MapResponseBodyLayer;
pub mod future; pub mod future;
pub mod or; mod or;
pub use self::method_filter::MethodFilter; pub use self::{method_filter::MethodFilter, or::Or};
mod method_filter; mod method_filter;
@@ -479,7 +479,8 @@ impl<S> Router<S> {
/// # async fn teams_list() {} /// # async fn teams_list() {}
/// ///
/// // define some routes separately /// // define some routes separately
/// let user_routes = Router::new().route("/users", get(users_list)) /// let user_routes = Router::new()
/// .route("/users", get(users_list))
/// .route("/users/:id", get(users_show)); /// .route("/users/:id", get(users_show));
/// ///
/// let team_routes = Router::new().route("/teams", get(teams_list)); /// let team_routes = Router::new().route("/teams", get(teams_list));
@@ -490,8 +491,8 @@ impl<S> Router<S> {
/// # hyper::Server::bind(&"".parse().unwrap()).serve(app.into_make_service()).await.unwrap(); /// # hyper::Server::bind(&"".parse().unwrap()).serve(app.into_make_service()).await.unwrap();
/// # }; /// # };
/// ``` /// ```
pub fn or<S2>(self, other: S2) -> Router<or::Or<S, S2>> { pub fn or<S2>(self, other: S2) -> Router<Or<S, S2>> {
self.map(|first| or::Or { self.map(|first| Or {
first, first,
second: other, second: other,
}) })