Unverified Commit 6e312389 authored by Matteo Bigoi's avatar Matteo Bigoi Committed by GitHub
Browse files

Better handling of documentation for Router (#872)

parent 8293b677
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ pub mod rejection;
pub use self::body::{Body, BoxBody, HttpBody};
#[doc(inline)]
pub use self::error::Error;
#[doc(inline)]
pub use self::routing::Router;

/// Alias for a type-erased error type.
pub type BoxError = Box<dyn std::error::Error + Send + Sync>;
+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
 */

//! Future types.

use crate::body::BoxBody;
use futures_util::future::Either;
use http::{Request, Response};
+4 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ mod route;

pub use self::{into_make_service::IntoMakeService, route::Route};

/// The router type for composing handlers and services.
#[derive(Debug)]
pub struct Router<B = Body> {
    routes: Vec<(Route<B>, RequestSpec)>,
@@ -63,11 +64,13 @@ where
    ///
    /// Unless you add additional routes this will respond to `404 Not Found` to
    /// all requests.
    #[doc(hidden)]
    pub fn new() -> Self {
        Self { routes: Default::default() }
    }

    /// Add a route to the router.
    #[doc(hidden)]
    pub fn route<T>(mut self, request_spec: RequestSpec, svc: T) -> Self
    where
        T: Service<Request<B>, Response = Response<BoxBody>, Error = Infallible> + Clone + Send + 'static,
@@ -84,6 +87,7 @@ where
    /// [`Server`](hyper::server::Server).
    ///
    /// [`MakeService`]: tower::make::MakeService
    #[doc(hidden)]
    pub fn into_make_service(self) -> IntoMakeService<Self> {
        IntoMakeService::new(self)
    }