1extern crate iron;
2extern crate iron_error_router;
3
4use iron::prelude::*;
5use iron::status;
6
7fn main() {
8 let handler = |_: &mut Request| {
9 Ok(Response::with((status::NotFound)))
10 };
11
12 let mut chain = Chain::new(handler);
13 chain.link_after({
14 let mut error_router = iron_error_router::ErrorRouter::new();
15
16 error_router.handle_status(status::NotFound, |_: &mut Request| {
19 Ok(Response::with((
20 status::NotFound,
21 "Content not found."
22 )))
23 });
24
25 error_router.modifier_for_status(
28 status::NotFound,
29 (status::NotFound, "Content not found.")
30 );
31
32 error_router.after_status(status::NotFound, |_: &mut Request, _: Response| {
35 Ok(Response::with((status::NotFound, "Content not found.")))
36 });
37
38 error_router
39 });
40
41 Iron::new(chain).http("localhost:3000").unwrap();
42}