Macro mini_server::expand
source ยท macro_rules! expand { ($exprs: expr, $name: expr, $against: path) => { ... }; }
Expand description
Get the value of a path dynamic variable
use mini_server::*;
let mut app = HTTPServer::new("localhost:4221");
app.get("/hello/@name/#age", |_, exprs| {
let name = expand!(exprs, "name", PathExpr::String);
let age = expand!(exprs, "age", PathExpr::Number);
let mut response = HTTPResponse::default();
response.set_body(
format!("Hello {name}, you are {age}!")
.as_bytes()
.to_vec(),
);
response
});