diff options
| author | Fuwn <[email protected]> | 2022-03-27 11:03:29 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-27 11:03:29 +0000 |
| commit | 0b297db77fc297ff3a65d15ced67e2f9b2630c1d (patch) | |
| tree | b97c12c015f8fb76a278161680ddeedeb36899bd /examples | |
| parent | docs: add missing dependency (diff) | |
| download | windmark-0b297db77fc297ff3a65d15ced67e2f9b2630c1d.tar.xz windmark-0b297db77fc297ff3a65d15ced67e2f9b2630c1d.zip | |
feat(error_handle): fnmut closure
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/windmark.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/examples/windmark.rs b/examples/windmark.rs index 6ceeaf7..a5bfc9a 100644 --- a/examples/windmark.rs +++ b/examples/windmark.rs @@ -25,11 +25,19 @@ use windmark::Response; #[windmark::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { + let mut error_count = 0; + windmark::Router::new() .set_private_key_file("windmark_private.pem") .set_certificate_chain_file("windmark_pair.pem") .enable_default_logger(true) - .set_error_handler(|_| Response::PermanentFailure("error...".to_string())) + .set_error_handler(Box::new(move |_| { + error_count += 1; + + println!("{} errors so far", error_count); + + Response::PermanentFailure("e".into()) + })) .attach(|r| { r.mount("/module", |_| Response::Success("This is a module!".into())); }) |