use std::process::ExitCode;
use via::{Error, Next, Request, Response, Server};
async fn hello(request: Request, _: Next) -> via::Result {
let name = request.param("name").decode().into_result()?;
Response::build().text(format!("Hello, {}!", name.as_ref()))
}
#[tokio::main]
async fn main() -> Result<ExitCode, Error> {
let mut app = via::app(());
app.route("/hello/:name").to(via::get(hello));
Server::new(app).listen(("127.0.0.1", 8080)).await
}