diff --git a/examples/configuration.rs b/examples/configuration.rs index 2ec0a29fb..f376ae06e 100644 --- a/examples/configuration.rs +++ b/examples/configuration.rs @@ -1,6 +1,7 @@ #![feature(async_await, futures_api)] -use tide::{head::Path, ExtractConfiguration}; +use futures::future::FutureObj; +use tide::{head::Path, middleware::RequestContext, ExtractConfiguration, Response}; /// A type that represents how much value will be added by the `add` handler. #[derive(Clone, Debug, Default)] @@ -16,10 +17,16 @@ async fn add( format!("{} plus {} is {}", base, amount, base + amount) } +fn debug_store(ctx: RequestContext<()>) -> FutureObj { + println!("{:#?}", ctx.store()); + ctx.next() +} + fn main() { let mut app = tide::App::new(()); // `App::config` sets the default configuration of the app (that is, a top-level router). app.config(IncreaseBy(1)); + app.middleware(debug_store); app.at("add_one/{}").get(add); // `IncreaseBy` is set to 1 app.at("add_two/{}").get(add).config(IncreaseBy(2)); // `IncreaseBy` is overridden to 2