use touche::{body::HttpBody, Body, Method, Request, Response, Server, StatusCode}; fn main() -> std::io::Result<()> { Server::builder() .bind("0.0.0.0:4444") .serve(|req: Request
| { match (req.method(), req.uri().path()) { (_, "/") => Response::builder() .status(StatusCode::OK) .body(Body::from("Usage: curl -d hello localhost:4444/echo\n")), // Responds with the same payload (&Method::POST, "/echo") => Response::builder() .status(StatusCode::OK) .body(req.into_body()), // Responds with the reversed payload (&Method::POST, "/reverse") => { let body = req.into_body().into_bytes().unwrap_or_default(); match std::str::from_utf8(&body) { Ok(message) => Response::builder() .status(StatusCode::OK) .body(message.chars().rev().collect::