diff --git a/src/lib.rs b/src/lib.rs index 60cc9369..37bcd423 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -599,6 +599,9 @@ pub mod response; pub mod routing; pub mod service; +#[cfg(test)] +mod tests; + #[doc(inline)] pub use self::{ handler::{get, on, post, Handler}, @@ -609,6 +612,9 @@ pub use async_trait::async_trait; pub use tower_http::add_extension::{AddExtension, AddExtensionLayer}; pub mod prelude { + //! Re-exports of important traits, types, and functions used with tower-web. Meant to be glob + //! imported. + pub use crate::{ body::Body, extract, @@ -626,26 +632,7 @@ where routing::EmptyRouter.route(spec, svc) } -#[cfg(test)] -mod tests; - -pub(crate) trait ResultExt { - fn unwrap_infallible(self) -> T; -} - -impl ResultExt for Result { - fn unwrap_infallible(self) -> T { - match self { - Ok(value) => value, - Err(err) => match err {}, - } - } -} - pub trait ServiceExt: Service, Response = Response> { - // TODO(david): routing methods like get, post, etc like whats on OnMethod - // so you can do `route("...", service::get(svc).post(svc))` - fn handle_error(self, f: F) -> service::HandleError where Self: Sized, @@ -659,3 +646,16 @@ pub trait ServiceExt: Service, Response = Response> { } impl ServiceExt for S where S: Service, Response = Response> {} + +pub(crate) trait ResultExt { + fn unwrap_infallible(self) -> T; +} + +impl ResultExt for Result { + fn unwrap_infallible(self) -> T { + match self { + Ok(value) => value, + Err(err) => match err {}, + } + } +}