extern crate env_logger; #[macro_use] extern crate log; extern crate simple_test_bbarekas; use simple_test_bbarekas::{Method, Server, StatusCode}; fn main() { let host = "127.0.0.1"; let port = "7878"; let server = Server::new(|request, mut response| { info!("Request received. {} {}", request.method(), request.uri()); match (request.method(), request.uri().path()) { (&Method::GET, "/hello") => { Ok(response.body("

Hi!

Hello Rust!

".as_bytes().to_vec())?) } (_, _) => { response.status(StatusCode::NOT_FOUND); Ok(response.body("

404

Not found!

".as_bytes().to_vec())?) } } }); server.listen(host, port); }