use afire::{Content, Method, Response, Server, Status};
use crate::Example;
pub struct Routing;
impl Example for Routing {
fn name(&self) -> &'static str {
"routing"
}
fn exec(&self) {
let mut server: Server = Server::<()>::new("localhost", 8080);
server.route(Method::ANY, "**", |_req| {
Response::new()
.status(Status::NotFound)
.text("The page you are looking for does not exist :/")
.content(Content::TXT)
});
server.route(Method::GET, "/", |_req| {
Response::new().text("Hello World!").content(Content::TXT)
});
server.start().unwrap();
}
}