use rustigo::prelude::*; fn books(stream: TcpStream, _: Request) { html!(stream; "

1, 2, 3

"); } fn book(stream: TcpStream, request: Request) { let book: i32 = request .resource .split("/book/") .collect::() .parse() .unwrap(); if !(1..4).contains(&book) { html!(stream; "

That book doesn't exist.

"); return; } let text = format!("

Loading book {book}

"); html!(stream; text); } fn main() { let mut rustigo = Rustigo::default(); rustigo.handle("/", books).handle("/book*", book); rustigo.listen("localhost:7878", 4).unwrap(); }