diff --git a/examples/cookies/introduction/src/main.rs b/examples/cookies/introduction/src/main.rs index 49f4f569..6bf67cc0 100644 --- a/examples/cookies/introduction/src/main.rs +++ b/examples/cookies/introduction/src/main.rs @@ -7,9 +7,9 @@ use gotham::hyper::{Body, Response, StatusCode}; use gotham::middleware::cookie::CookieParser; use gotham::mime::TEXT_PLAIN; use gotham::pipeline::{new_pipeline, single_pipeline}; -use gotham::router::builder::*; -use gotham::router::Router; -use gotham::state::{FromState, State}; +use gotham::prelude::*; +use gotham::router::{build_router, Router}; +use gotham::state::State; /// The first request will set a cookie, and subsequent requests will echo it back. fn handler(state: State) -> (State, Response) { diff --git a/examples/custom_service/src/main.rs b/examples/custom_service/src/main.rs index 46c8a60d..109194af 100644 --- a/examples/custom_service/src/main.rs +++ b/examples/custom_service/src/main.rs @@ -5,8 +5,8 @@ use futures_util::future::{BoxFuture, FutureExt}; use gotham::hyper::server::conn::Http; use gotham::hyper::service::Service; use gotham::hyper::{Body, Request, Response}; -use gotham::router::builder::*; -use gotham::router::Router; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; use gotham::service::call_handler; use gotham::state::State; use std::net::SocketAddr; diff --git a/examples/diesel/src/main.rs b/examples/diesel/src/main.rs index 05f12c82..f49e442a 100644 --- a/examples/diesel/src/main.rs +++ b/examples/diesel/src/main.rs @@ -10,14 +10,14 @@ extern crate diesel_migrations; use diesel::prelude::*; use diesel::sqlite::SqliteConnection; use futures_util::FutureExt; -use gotham::handler::{HandlerError, HandlerFuture, MapHandlerError, MapHandlerErrorFuture}; +use gotham::handler::{HandlerError, HandlerFuture}; use gotham::helpers::http::response::create_response; use gotham::hyper::{body, Body, StatusCode}; use gotham::mime::APPLICATION_JSON; use gotham::pipeline::{new_pipeline, single_pipeline}; -use gotham::router::builder::*; -use gotham::router::Router; -use gotham::state::{FromState, State}; +use gotham::prelude::*; +use gotham::router::{build_router, Router}; +use gotham::state::State; use gotham_middleware_diesel::DieselMiddleware; use serde::Serialize; use std::pin::Pin; diff --git a/examples/example_contribution_template/name/src/main.rs b/examples/example_contribution_template/name/src/main.rs index d11960e6..21793857 100644 --- a/examples/example_contribution_template/name/src/main.rs +++ b/examples/example_contribution_template/name/src/main.rs @@ -21,8 +21,8 @@ //! you're writing an example for setting Cookies. use gotham::helpers::http::response::create_empty_response; use gotham::hyper::{Body, Response, StatusCode}; -use gotham::router::builder::*; -use gotham::router::Router; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; use gotham::state::State; /// Create a `Handler` that ... diff --git a/examples/finalizers/src/main.rs b/examples/finalizers/src/main.rs index 0cbed5a5..bbd393d1 100644 --- a/examples/finalizers/src/main.rs +++ b/examples/finalizers/src/main.rs @@ -1,9 +1,9 @@ //! An finalizer example use gotham::hyper::body::Body; use gotham::hyper::{Response, StatusCode}; -use gotham::router::builder::*; +use gotham::prelude::*; use gotham::router::response::ResponseExtender; -use gotham::router::Router; +use gotham::router::{build_simple_router, Router}; use gotham::state::State; const HELLO_ROUTER: &str = "Hello Router!"; diff --git a/examples/handlers/async_handlers/src/main.rs b/examples/handlers/async_handlers/src/main.rs index 0ab6993e..0d8c6f5f 100644 --- a/examples/handlers/async_handlers/src/main.rs +++ b/examples/handlers/async_handlers/src/main.rs @@ -12,10 +12,10 @@ use gotham::hyper::StatusCode; #[cfg(not(test))] use gotham::hyper::{body, Client, Uri}; use gotham::mime::TEXT_PLAIN; -use gotham::router::builder::{build_simple_router, DefineSingleRoute, DrawRoutes}; -use gotham::router::response::StaticResponseExtender; +use gotham::prelude::*; +use gotham::router::builder::build_simple_router; use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::state::State; type ResponseContentFuture = Pin, gotham::hyper::Error>> + Send>>; diff --git a/examples/handlers/form_urlencoded/src/main.rs b/examples/handlers/form_urlencoded/src/main.rs index 994a5cd5..ae73af4a 100644 --- a/examples/handlers/form_urlencoded/src/main.rs +++ b/examples/handlers/form_urlencoded/src/main.rs @@ -1,15 +1,17 @@ //! An example of decoding requests from an HTML form element + use futures_util::future::{self, FutureExt}; +use std::pin::Pin; +use url::form_urlencoded; use gotham::handler::HandlerFuture; use gotham::helpers::http::response::create_response; use gotham::hyper::{body, Body, StatusCode}; use gotham::mime::TEXT_PLAIN; -use gotham::router::builder::{build_simple_router, DefineSingleRoute, DrawRoutes}; +use gotham::prelude::*; +use gotham::router::builder::build_simple_router; use gotham::router::Router; -use gotham::state::{FromState, State}; -use std::pin::Pin; -use url::form_urlencoded; +use gotham::state::State; /// Extracts the elements of the POST request and responds with the form keys and values fn form_handler(mut state: State) -> Pin> { diff --git a/examples/handlers/multipart/src/main.rs b/examples/handlers/multipart/src/main.rs index c7020273..adbe750d 100644 --- a/examples/handlers/multipart/src/main.rs +++ b/examples/handlers/multipart/src/main.rs @@ -5,9 +5,10 @@ use gotham::helpers::http::response::create_response; use gotham::hyper::header::CONTENT_TYPE; use gotham::hyper::{body, Body, HeaderMap, StatusCode}; use gotham::mime::TEXT_PLAIN; -use gotham::router::builder::{build_simple_router, DefineSingleRoute, DrawRoutes}; +use gotham::prelude::*; +use gotham::router::builder::build_simple_router; use gotham::router::Router; -use gotham::state::{FromState, State}; +use gotham::state::State; use multipart::server::Multipart; use std::io::{Cursor, Read}; use std::pin::Pin; diff --git a/examples/handlers/request_data/src/main.rs b/examples/handlers/request_data/src/main.rs index d909b0ee..bf322e53 100644 --- a/examples/handlers/request_data/src/main.rs +++ b/examples/handlers/request_data/src/main.rs @@ -1,13 +1,14 @@ //! A basic example showing the request components use futures_util::future::{self, FutureExt}; -use gotham::hyper::{body, Body, HeaderMap, Method, Response, StatusCode, Uri, Version}; use std::pin::Pin; use gotham::handler::HandlerFuture; use gotham::helpers::http::response::create_empty_response; -use gotham::router::builder::{build_simple_router, DefineSingleRoute, DrawRoutes}; +use gotham::hyper::{body, Body, HeaderMap, Method, Response, StatusCode, Uri, Version}; +use gotham::prelude::*; +use gotham::router::builder::build_simple_router; use gotham::router::Router; -use gotham::state::{FromState, State}; +use gotham::state::State; /// Extract the main elements of the request except for the `Body` fn print_request_elements(state: &State) { diff --git a/examples/handlers/simple_async_handlers/src/main.rs b/examples/handlers/simple_async_handlers/src/main.rs index 082972af..ca5547f0 100644 --- a/examples/handlers/simple_async_handlers/src/main.rs +++ b/examples/handlers/simple_async_handlers/src/main.rs @@ -11,10 +11,10 @@ use gotham::handler::HandlerFuture; use gotham::helpers::http::response::create_response; use gotham::hyper::StatusCode; use gotham::mime::TEXT_PLAIN; -use gotham::router::builder::{build_simple_router, DefineSingleRoute, DrawRoutes}; -use gotham::router::response::StaticResponseExtender; +use gotham::prelude::*; +use gotham::router::builder::build_simple_router; use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::state::State; #[derive(Deserialize, StateData, StaticResponseExtender)] struct QueryStringExtractor { diff --git a/examples/handlers/simple_async_handlers_await/src/main.rs b/examples/handlers/simple_async_handlers_await/src/main.rs index 8ab45dd4..9ef43120 100644 --- a/examples/handlers/simple_async_handlers_await/src/main.rs +++ b/examples/handlers/simple_async_handlers_await/src/main.rs @@ -1,13 +1,13 @@ //! A basic example showing the request components -use gotham::handler::{HandlerError, HandlerResult, IntoResponse}; +use gotham::handler::{HandlerError, HandlerResult}; use gotham::helpers::http::response::create_response; use gotham::hyper::{Body, StatusCode}; use gotham::mime::TEXT_PLAIN; -use gotham::router::builder::{build_simple_router, DefineSingleRoute, DrawRoutes}; -use gotham::router::response::StaticResponseExtender; +use gotham::prelude::*; +use gotham::router::builder::build_simple_router; use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::state::State; use serde::Deserialize; use std::time::Duration; use tokio::time::sleep; diff --git a/examples/handlers/stateful/src/main.rs b/examples/handlers/stateful/src/main.rs index b5300dd5..f61fa02c 100644 --- a/examples/handlers/stateful/src/main.rs +++ b/examples/handlers/stateful/src/main.rs @@ -7,10 +7,10 @@ use std::pin::Pin; use std::sync::{Arc, Mutex}; use std::time::SystemTime; -use gotham::anyhow::Result; -use gotham::handler::{Handler, HandlerFuture, IntoResponse, NewHandler}; -use gotham::router::builder::*; -use gotham::router::Router; +use gotham::anyhow; +use gotham::handler::{Handler, HandlerFuture, NewHandler}; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; use gotham::state::State; // A struct which can store the state which it needs. @@ -61,7 +61,7 @@ impl Handler for CountingHandler { impl NewHandler for CountingHandler { type Instance = Self; - fn new_handler(&self) -> Result { + fn new_handler(&self) -> anyhow::Result { Ok(self.clone()) } } diff --git a/examples/headers/setting/src/main.rs b/examples/headers/setting/src/main.rs index b4850375..40476f49 100644 --- a/examples/headers/setting/src/main.rs +++ b/examples/headers/setting/src/main.rs @@ -1,8 +1,8 @@ //! Setting a header value for a Gotham web framework response use gotham::helpers::http::response::create_empty_response; use gotham::hyper::{Body, Response, StatusCode}; -use gotham::router::builder::*; -use gotham::router::Router; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; use gotham::state::State; /// Create a `Handler` that adds a custom header. diff --git a/examples/into_response/introduction/src/main.rs b/examples/into_response/introduction/src/main.rs index a0fbe056..046be198 100644 --- a/examples/into_response/introduction/src/main.rs +++ b/examples/into_response/introduction/src/main.rs @@ -1,11 +1,10 @@ //! An introduction to the Gotham web framework's `IntoResponse` trait. -use gotham::handler::IntoResponse; use gotham::helpers::http::response::create_response; use gotham::hyper::{Body, Response, StatusCode}; use gotham::mime::APPLICATION_JSON; -use gotham::router::builder::*; -use gotham::router::Router; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; use gotham::state::State; use serde::Serialize; diff --git a/examples/middleware/introduction/src/main.rs b/examples/middleware/introduction/src/main.rs index 83cf4078..8f7f6f86 100644 --- a/examples/middleware/introduction/src/main.rs +++ b/examples/middleware/introduction/src/main.rs @@ -7,11 +7,11 @@ use gotham::handler::HandlerFuture; use gotham::helpers::http::response::create_empty_response; use gotham::hyper::header::{HeaderMap, USER_AGENT}; use gotham::hyper::{Body, Response, StatusCode}; -use gotham::middleware::{Middleware, NewMiddleware}; +use gotham::middleware::Middleware; use gotham::pipeline::{new_pipeline, single_pipeline}; -use gotham::router::builder::*; -use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::prelude::*; +use gotham::router::{build_router, Router}; +use gotham::state::State; /// A simple struct which holds an identifier for the user agent which made the request. /// diff --git a/examples/middleware/introduction_await/src/main.rs b/examples/middleware/introduction_await/src/main.rs index b7f9838b..f613cca2 100644 --- a/examples/middleware/introduction_await/src/main.rs +++ b/examples/middleware/introduction_await/src/main.rs @@ -6,11 +6,11 @@ use gotham::handler::HandlerFuture; use gotham::helpers::http::response::create_empty_response; use gotham::hyper::header::{HeaderMap, USER_AGENT}; use gotham::hyper::{Body, Response, StatusCode}; -use gotham::middleware::{Middleware, NewMiddleware}; +use gotham::middleware::Middleware; use gotham::pipeline::{new_pipeline, single_pipeline}; -use gotham::router::builder::*; -use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::prelude::*; +use gotham::router::{build_router, Router}; +use gotham::state::State; /// A simple struct which holds an identifier for the user agent which made the request. /// diff --git a/examples/middleware/multiple_pipelines/src/main.rs b/examples/middleware/multiple_pipelines/src/main.rs index 2c2d3853..a85ec413 100644 --- a/examples/middleware/multiple_pipelines/src/main.rs +++ b/examples/middleware/multiple_pipelines/src/main.rs @@ -20,11 +20,11 @@ use std::pin::Pin; use gotham::handler::HandlerFuture; use gotham::helpers::http::response::create_response; use gotham::middleware::session::NewSessionMiddleware; -use gotham::middleware::{Middleware, NewMiddleware}; +use gotham::middleware::Middleware; use gotham::pipeline::{finalize_pipeline_set, new_pipeline, new_pipeline_set, single_pipeline}; -use gotham::router::builder::*; -use gotham::router::Router; -use gotham::state::{FromState, State}; +use gotham::prelude::*; +use gotham::router::{build_router, Router}; +use gotham::state::State; use serde::{Deserialize, Serialize}; /// A simple struct to represent our default session data. diff --git a/examples/path/globs/src/main.rs b/examples/path/globs/src/main.rs index 3005a701..efadc9f0 100644 --- a/examples/path/globs/src/main.rs +++ b/examples/path/globs/src/main.rs @@ -1,9 +1,8 @@ //! Shows how to match arbitrarily many path segments. -use gotham::router::builder::*; -use gotham::router::response::StaticResponseExtender; -use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; +use gotham::state::State; use serde::Deserialize; #[derive(Deserialize, StateData, StaticResponseExtender)] diff --git a/examples/path/introduction/src/main.rs b/examples/path/introduction/src/main.rs index 2389f21a..f41dec50 100644 --- a/examples/path/introduction/src/main.rs +++ b/examples/path/introduction/src/main.rs @@ -1,10 +1,9 @@ //! An introduction to extracting request path segments, in a type safe way, with the //! Gotham web framework -use gotham::router::builder::*; -use gotham::router::response::StaticResponseExtender; -use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; +use gotham::state::State; use serde::Deserialize; /// Holds data extracted from the Request path. diff --git a/examples/path/regex/src/main.rs b/examples/path/regex/src/main.rs index 49399df5..db1cfe1b 100644 --- a/examples/path/regex/src/main.rs +++ b/examples/path/regex/src/main.rs @@ -1,9 +1,8 @@ //! An example of the Gotham web framework `Router` that shows how to use Regex patterns in path segments. -use gotham::router::builder::*; -use gotham::router::response::StaticResponseExtender; -use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; +use gotham::state::State; use serde::Deserialize; #[derive(Deserialize, StateData, StaticResponseExtender)] diff --git a/examples/query_string/introduction/src/main.rs b/examples/query_string/introduction/src/main.rs index 6a52d2f5..3f393e23 100644 --- a/examples/query_string/introduction/src/main.rs +++ b/examples/query_string/introduction/src/main.rs @@ -2,10 +2,9 @@ //! Gotham web framework use gotham::mime::{Mime, APPLICATION_JSON}; -use gotham::router::builder::*; -use gotham::router::response::StaticResponseExtender; -use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; +use gotham::state::State; use serde::{Deserialize, Serialize}; /// Holds data extracted from the Request query string. diff --git a/examples/routing/associations/src/handlers.rs b/examples/routing/associations/src/handlers.rs index 4424ff7a..794bb7a6 100644 --- a/examples/routing/associations/src/handlers.rs +++ b/examples/routing/associations/src/handlers.rs @@ -3,7 +3,7 @@ //! We've used a macro here for brevity but this is NOT how you would implement a handler in //! a real world application. -use gotham::handler::IntoResponse; +use gotham::prelude::*; use gotham::state::State; macro_rules! generic_handler { diff --git a/examples/routing/associations/src/main.rs b/examples/routing/associations/src/main.rs index a15b9f6f..de73727f 100644 --- a/examples/routing/associations/src/main.rs +++ b/examples/routing/associations/src/main.rs @@ -1,8 +1,8 @@ //! An example of the Gotham web framework `Router` that shows how to associate multiple handlers //! to a single path. use gotham::hyper::Method; -use gotham::router::builder::*; -use gotham::router::Router; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; mod handlers; use self::handlers::*; diff --git a/examples/routing/http_verbs/src/handlers.rs b/examples/routing/http_verbs/src/handlers.rs index 22a1b961..a838e119 100644 --- a/examples/routing/http_verbs/src/handlers.rs +++ b/examples/routing/http_verbs/src/handlers.rs @@ -3,7 +3,7 @@ //! We've used a macro here for brevity but this is NOT how you would implement a handler in //! a real world application. -use gotham::handler::IntoResponse; +use gotham::prelude::*; use gotham::state::State; macro_rules! generic_handler { diff --git a/examples/routing/http_verbs/src/main.rs b/examples/routing/http_verbs/src/main.rs index d1069454..b6201e3d 100644 --- a/examples/routing/http_verbs/src/main.rs +++ b/examples/routing/http_verbs/src/main.rs @@ -1,8 +1,8 @@ //! An example of the Gotham web framework Router that shows how to route requests to handlers //! based on HTTP verbs. use gotham::hyper::Method; -use gotham::router::builder::*; -use gotham::router::Router; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; mod handlers; use self::handlers::*; diff --git a/examples/routing/introduction/src/main.rs b/examples/routing/introduction/src/main.rs index 90fabc3a..8648ec25 100644 --- a/examples/routing/introduction/src/main.rs +++ b/examples/routing/introduction/src/main.rs @@ -1,6 +1,6 @@ //! An introduction to fundamental `Router` and `Router Builder` concepts to create a routing tree. -use gotham::router::builder::*; -use gotham::router::Router; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; use gotham::state::State; const HELLO_ROUTER: &str = "Hello Router!"; diff --git a/examples/routing/scopes/src/handlers.rs b/examples/routing/scopes/src/handlers.rs index 4424ff7a..794bb7a6 100644 --- a/examples/routing/scopes/src/handlers.rs +++ b/examples/routing/scopes/src/handlers.rs @@ -3,7 +3,7 @@ //! We've used a macro here for brevity but this is NOT how you would implement a handler in //! a real world application. -use gotham::handler::IntoResponse; +use gotham::prelude::*; use gotham::state::State; macro_rules! generic_handler { diff --git a/examples/routing/scopes/src/main.rs b/examples/routing/scopes/src/main.rs index edb28365..c20d6946 100644 --- a/examples/routing/scopes/src/main.rs +++ b/examples/routing/scopes/src/main.rs @@ -1,8 +1,8 @@ //! An example of the Gotham web framework `Router` that shows how to combine `Routes` //! under a common root using scopes. use gotham::hyper::Method; -use gotham::router::builder::*; -use gotham::router::Router; +use gotham::prelude::*; +use gotham::router::{build_simple_router, Router}; mod handlers; use self::handlers::*; diff --git a/examples/sessions/custom_data_type/src/main.rs b/examples/sessions/custom_data_type/src/main.rs index dff9962b..d8997b5e 100644 --- a/examples/sessions/custom_data_type/src/main.rs +++ b/examples/sessions/custom_data_type/src/main.rs @@ -3,9 +3,9 @@ use gotham::middleware::session::{NewSessionMiddleware, SessionData}; use gotham::pipeline::{new_pipeline, single_pipeline}; -use gotham::router::builder::*; -use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::prelude::*; +use gotham::router::{build_router, Router}; +use gotham::state::State; use serde::{Deserialize, Serialize}; use time::format_description::well_known::Rfc3339; use time::OffsetDateTime; diff --git a/examples/sessions/introduction/src/main.rs b/examples/sessions/introduction/src/main.rs index d1027faf..b77a0cf8 100644 --- a/examples/sessions/introduction/src/main.rs +++ b/examples/sessions/introduction/src/main.rs @@ -5,9 +5,9 @@ use gotham::middleware::session::{NewSessionMiddleware, SessionData}; use gotham::pipeline::{new_pipeline, single_pipeline}; -use gotham::router::builder::*; -use gotham::router::Router; -use gotham::state::{FromState, State}; +use gotham::prelude::*; +use gotham::router::{build_router, Router}; +use gotham::state::State; /// Handler function for `GET` requests directed to `/` /// diff --git a/examples/shared_state/src/main.rs b/examples/shared_state/src/main.rs index 65c122de..53935aa1 100644 --- a/examples/shared_state/src/main.rs +++ b/examples/shared_state/src/main.rs @@ -8,9 +8,9 @@ use gotham::middleware::state::StateMiddleware; use gotham::pipeline::{single_middleware, single_pipeline}; -use gotham::router::builder::*; -use gotham::router::Router; -use gotham::state::{FromState, State, StateData}; +use gotham::prelude::*; +use gotham::router::{build_router, Router}; +use gotham::state::State; use std::sync::{Arc, Mutex}; diff --git a/examples/static_assets/src/main.rs b/examples/static_assets/src/main.rs index 2500a387..c5971ae3 100644 --- a/examples/static_assets/src/main.rs +++ b/examples/static_assets/src/main.rs @@ -1,6 +1,7 @@ //! An example of serving static assets with Gotham. use gotham::handler::FileOptions; -use gotham::router::builder::{build_simple_router, DefineSingleRoute, DrawRoutes}; +use gotham::prelude::*; +use gotham::router::builder::build_simple_router; pub fn main() { let path = std::env::args() diff --git a/examples/websocket/src/main.rs b/examples/websocket/src/main.rs index 8b8f48e9..6c4992f4 100644 --- a/examples/websocket/src/main.rs +++ b/examples/websocket/src/main.rs @@ -1,7 +1,8 @@ use futures_util::{Sink, SinkExt, Stream, StreamExt}; use gotham::hyper::upgrade::OnUpgrade; use gotham::hyper::{Body, HeaderMap, Response, StatusCode}; -use gotham::state::{request_id, FromState, State}; +use gotham::prelude::*; +use gotham::state::{request_id, State}; mod ws; diff --git a/gotham/src/extractor/path.rs b/gotham/src/extractor/path.rs index 1fdca73b..0cc2f3f3 100644 --- a/gotham/src/extractor/path.rs +++ b/gotham/src/extractor/path.rs @@ -21,11 +21,10 @@ use crate::state::{State, StateData}; /// /// ```rust /// # use hyper::{Body, Response, StatusCode}; -/// # use gotham::state::{FromState, State, StateData}; +/// # use gotham::state::{FromState, State}; /// # use gotham::helpers::http::response::create_response; -/// # use gotham::router::Router; -/// # use gotham::router::builder::*; -/// # use gotham::router::response::StaticResponseExtender; +/// # use gotham::router::{build_simple_router, Router}; +/// # use gotham::prelude::*; /// # use gotham::test::TestServer; /// # use serde::Deserialize; /// # diff --git a/gotham/src/extractor/query_string.rs b/gotham/src/extractor/query_string.rs index 38f38f6a..256cb98b 100644 --- a/gotham/src/extractor/query_string.rs +++ b/gotham/src/extractor/query_string.rs @@ -21,11 +21,10 @@ use crate::state::{State, StateData}; /// /// ```rust /// # use hyper::{Body, Response, StatusCode}; -/// # use gotham::state::{FromState, State, StateData}; +/// # use gotham::state::{FromState, State}; /// # use gotham::helpers::http::response::create_response; -/// # use gotham::router::Router; -/// # use gotham::router::builder::*; -/// # use gotham::router::response::StaticResponseExtender; +/// # use gotham::router::{build_simple_router, Router}; +/// # use gotham::prelude::*; /// # use gotham::test::TestServer; /// # use serde::Deserialize; /// # diff --git a/gotham/src/lib.rs b/gotham/src/lib.rs index 2db2ad73..edcc9bc1 100644 --- a/gotham/src/lib.rs +++ b/gotham/src/lib.rs @@ -31,6 +31,7 @@ pub mod handler; pub mod helpers; pub mod middleware; pub mod pipeline; +pub mod prelude; pub mod router; pub mod service; pub mod state; diff --git a/gotham/src/prelude.rs b/gotham/src/prelude.rs new file mode 100644 index 00000000..ffd49cc8 --- /dev/null +++ b/gotham/src/prelude.rs @@ -0,0 +1,8 @@ +//! A collection of useful traits and macros that should always be imported. + +#[cfg(feature = "derive")] +pub use gotham_derive::*; + +pub use crate::handler::{IntoHandlerFuture, IntoResponse, MapHandlerError, MapHandlerErrorFuture}; +pub use crate::router::builder::{DefineSingleRoute, DrawRoutes}; +pub use crate::state::FromState; diff --git a/gotham/src/router/builder/associated.rs b/gotham/src/router/builder/associated.rs index 45d609b4..0bcf3ad6 100644 --- a/gotham/src/router/builder/associated.rs +++ b/gotham/src/router/builder/associated.rs @@ -68,16 +68,12 @@ where /// # Examples /// /// ``` - /// # extern crate gotham; - /// # extern crate hyper; - /// # extern crate mime; - /// # /// # use hyper::{Body, Response, StatusCode}; /// # use hyper::header::ACCEPT; /// # use gotham::state::State; /// # use gotham::router::route::matcher::AcceptHeaderRouteMatcher; - /// # use gotham::router::Router; - /// # use gotham::router::builder::*; + /// # use gotham::router::{build_simple_router, Router}; + /// # use gotham::prelude::*; /// # use gotham::test::TestServer; /// # /// # fn my_handler(state: State) -> (State, Response) { @@ -137,10 +133,9 @@ where /// /// ```rust /// # use hyper::{Body, Response, StatusCode}; - /// # use gotham::router::Router; - /// # use gotham::router::builder::*; - /// # use gotham::router::response::StaticResponseExtender; - /// # use gotham::state::{State, StateData}; + /// # use gotham::router::{build_simple_router, Router}; + /// # use gotham::prelude::*; + /// # use gotham::state::State; /// # use gotham::test::TestServer; /// # use serde::Deserialize; /// # @@ -196,10 +191,9 @@ where /// /// ```rust /// # use hyper::{Body, Response, StatusCode}; - /// # use gotham::router::Router; - /// # use gotham::router::builder::*; - /// # use gotham::router::response::StaticResponseExtender; - /// # use gotham::state::{State, StateData}; + /// # use gotham::router::{build_simple_router, Router}; + /// # use gotham::prelude::*; + /// # use gotham::state::State; /// # use gotham::test::TestServer; /// # use serde::Deserialize; /// # diff --git a/gotham/src/router/builder/single.rs b/gotham/src/router/builder/single.rs index 69296e6f..505f1832 100644 --- a/gotham/src/router/builder/single.rs +++ b/gotham/src/router/builder/single.rs @@ -396,10 +396,9 @@ pub trait DefineSingleRoute { /// /// ```rust /// # use hyper::{Body, Response, StatusCode}; - /// # use gotham::state::{State, StateData, FromState}; - /// # use gotham::router::Router; - /// # use gotham::router::builder::*; - /// # use gotham::router::response::StaticResponseExtender; + /// # use gotham::state::{State, FromState}; + /// # use gotham::router::{build_router, Router}; + /// # use gotham::prelude::*; /// # use gotham::pipeline::*; /// # use gotham::middleware::session::NewSessionMiddleware; /// # use gotham::test::TestServer; @@ -459,10 +458,9 @@ pub trait DefineSingleRoute { /// /// ```rust /// # use hyper::{Body, Response, StatusCode}; - /// # use gotham::state::{State, StateData, FromState}; - /// # use gotham::router::Router; - /// # use gotham::router::builder::*; - /// # use gotham::router::response::StaticResponseExtender; + /// # use gotham::state::{State, FromState}; + /// # use gotham::router::{build_router, Router}; + /// # use gotham::prelude::*; /// # use gotham::pipeline::*; /// # use gotham::middleware::session::NewSessionMiddleware; /// # use gotham::test::TestServer; diff --git a/gotham/src/router/mod.rs b/gotham/src/router/mod.rs index b4eff512..557211b9 100644 --- a/gotham/src/router/mod.rs +++ b/gotham/src/router/mod.rs @@ -1,6 +1,8 @@ //! Defines the Gotham `Router` and supporting types. pub mod builder; +pub use builder::{build_router, build_simple_router}; + pub mod response; pub mod route; pub mod tree; diff --git a/middleware/diesel/src/repo.rs b/middleware/diesel/src/repo.rs index 58a69da0..c2a31bb0 100644 --- a/middleware/diesel/src/repo.rs +++ b/middleware/diesel/src/repo.rs @@ -1,6 +1,6 @@ use diesel::r2d2::ConnectionManager; use diesel::Connection; -use gotham::state::StateData; +use gotham::prelude::*; use log::error; use r2d2::{CustomizeConnection, Pool, PooledConnection}; use tokio::task; diff --git a/middleware/jwt/src/state_data.rs b/middleware/jwt/src/state_data.rs index 4f3c36d7..fc959340 100644 --- a/middleware/jwt/src/state_data.rs +++ b/middleware/jwt/src/state_data.rs @@ -1,4 +1,4 @@ -use gotham::state::StateData; +use gotham::prelude::*; pub use jsonwebtoken::TokenData; /// Struct to contain the JSON Web Token on a per-request basis.