#![deny(warnings)] use http::StatusCode; use rweb::*; #[get("/{word}")] async fn dyn_reply(word: String) -> Result, warp::Rejection> { if &word == "hello" { // a cast is needed for now, see https://github.com/rust-lang/rust/issues/60424 Ok(Box::new("world") as Box) } else { Ok(Box::new(StatusCode::BAD_REQUEST) as Box) } } #[tokio::main] async fn main() { warp::serve(dyn_reply()).run(([127, 0, 0, 1], 3030)).await; }