body/body.rs
1use express_rs::Express;
2
3/// This example demonstrates how to access the body of a request.
4/// Test it by POSTing a request with any body to port 8080
5fn main() {
6 let mut app = Express::new();
7 app.post("/", |req, res| {
8 if let Some(body) = &req.body {
9 res.send(body.to_string());
10 } else {
11 res.send("Nobody here...".to_string());
12 }
13 });
14
15 let port = 8080;
16 println!("Starting server on port {}", port);
17 app.listen(port);
18}