Skip to content

Commit e705b58

Browse files
committed
Add configuration debug example
1 parent 262985a commit e705b58

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/configuration.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(async_await, futures_api)]
22

3-
use tide::{head::Path, ExtractConfiguration};
3+
use futures::future::FutureObj;
4+
use tide::{head::Path, middleware::RequestContext, ExtractConfiguration, Response};
45

56
/// A type that represents how much value will be added by the `add` handler.
67
#[derive(Clone, Debug, Default)]
@@ -16,10 +17,16 @@ async fn add(
1617
format!("{} plus {} is {}", base, amount, base + amount)
1718
}
1819

20+
fn debug_store(ctx: RequestContext<()>) -> FutureObj<Response> {
21+
println!("{:#?}", ctx.store());
22+
ctx.next()
23+
}
24+
1925
fn main() {
2026
let mut app = tide::App::new(());
2127
// `App::config` sets the default configuration of the app (that is, a top-level router).
2228
app.config(IncreaseBy(1));
29+
app.middleware(debug_store);
2330
app.at("add_one/{}").get(add); // `IncreaseBy` is set to 1
2431
app.at("add_two/{}").get(add).config(IncreaseBy(2)); // `IncreaseBy` is overridden to 2
2532

0 commit comments

Comments
 (0)