extern crate ferrum; #[macro_use] extern crate ferrum_router; // To run, $ cargo run --example simple_with_macro // To use, go to http://localhost:3000/test and see output "test" // Or, go to http://localhost:3000 to see a default "OK" use ferrum::{Ferrum, FerrumResult, mime, Request, Response}; use ferrum_router::{Router}; fn main() { let router = router!( get "/" => handler "root", get "/{query}" => query_handler "query" ); Ferrum::new(router).http("localhost:3000").unwrap(); fn handler(_: &mut Request) -> FerrumResult { Ok(Response::new().with_content("OK", mime::TEXT_PLAIN)) } fn query_handler(request: &mut Request) -> FerrumResult { let query = request.extensions.get::().unwrap() .get("query").map(|value| value.as_str()).unwrap_or("/"); Ok(Response::new().with_content(query, mime::TEXT_PLAIN)) } }