diff --git a/src/app.rs b/src/app.rs index d06ef5a..222dc44 100644 --- a/src/app.rs +++ b/src/app.rs @@ -44,7 +44,7 @@ use crate::{handler::Handler, router::Router, Error, ServerError}; /// with `:`. For example, `/a/b/c` will always only match one route, while `/a/:b/c` will match /// any route with `/a//c`. /// -/// Variadic path components are accessible through the [Params] implementation. Paths are +/// Variadic path components are accessible through the [crate::Params] implementation. Paths are /// typically used through [crate::app::App] methods that use a string form of the Path. /// #[derive(Clone)] @@ -81,55 +81,55 @@ impl App { self.global_state.clone() } - /// Create a route for a GET request. See [crate::path::Path] and [crate::handler::Handler] for + /// Create a route for a GET request. See App's docs and [crate::handler::Handler] for /// more information. pub fn get(&mut self, path: &str, ch: Handler) { self.router.add(Method::GET, path.to_string(), ch); } - /// Create a route for a POST request. See [crate::path::Path] and [crate::handler::Handler] for + /// Create a route for a POST request. See App's docs and [crate::handler::Handler] for /// more information. pub fn post(&mut self, path: &str, ch: Handler) { self.router.add(Method::POST, path.to_string(), ch); } - /// Create a route for a DELETE request. See [crate::path::Path] and [crate::handler::Handler] for + /// Create a route for a DELETE request. See App's docs and [crate::handler::Handler] for /// more information. pub fn delete(&mut self, path: &str, ch: Handler) { self.router.add(Method::DELETE, path.to_string(), ch); } - /// Create a route for a PUT request. See [crate::path::Path] and [crate::handler::Handler] for + /// Create a route for a PUT request. See App's docs and [crate::handler::Handler] for /// more information. pub fn put(&mut self, path: &str, ch: Handler) { self.router.add(Method::PUT, path.to_string(), ch); } - /// Create a route for an OPTIONS request. See [crate::path::Path] and + /// Create a route for an OPTIONS request. See App's docs and /// [crate::handler::Handler] for more information. pub fn options(&mut self, path: &str, ch: Handler) { self.router.add(Method::OPTIONS, path.to_string(), ch); } - /// Create a route for a PATCH request. See [crate::path::Path] and + /// Create a route for a PATCH request. See App's docs and /// [crate::handler::Handler] for more information. pub fn patch(&mut self, path: &str, ch: Handler) { self.router.add(Method::PATCH, path.to_string(), ch); } - /// Create a route for a HEAD request. See [crate::path::Path] and + /// Create a route for a HEAD request. See App's docs and /// [crate::handler::Handler] for more information. pub fn head(&mut self, path: &str, ch: Handler) { self.router.add(Method::HEAD, path.to_string(), ch); } - /// Create a route for a CONNECT request. See [crate::path::Path] and + /// Create a route for a CONNECT request. See App's docs and /// [crate::handler::Handler] for more information. pub fn connect(&mut self, path: &str, ch: Handler) { self.router.add(Method::CONNECT, path.to_string(), ch); } - /// Create a route for a TRACE request. See [crate::path::Path] and + /// Create a route for a TRACE request. See App's docs and /// [crate::handler::Handler] for more information. pub fn trace(&mut self, path: &str, ch: Handler) { self.router.add(Method::TRACE, path.to_string(), ch); diff --git a/src/handler.rs b/src/handler.rs index 18036cc..92ebe36 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -6,6 +6,8 @@ use async_recursion::async_recursion; use http::{Request, Response}; use hyper::Body; +/// HandlerFunc is the type signature of all handlers. All handlers must conform to this pattern to +/// be used with `compose_handler!`. pub type HandlerFunc = fn( req: Request, response: Option>, diff --git a/src/lib.rs b/src/lib.rs index b0e0076..52e3687 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,6 +74,14 @@ where /// returned. pub type HTTPResult = Result<(Request, Option>), Error>; +/// A convenience import to gather all of `ratpack`'s dependencies in one easy place. +/// To use: +/// +/// ``` +/// use ratpack::prelude::*; +/// ``` pub mod prelude { pub use crate::{app::App, compose_handler, Error, HTTPResult, Params, ServerError}; + pub use http::{Request, Response, StatusCode}; + pub use hyper::Body; }