express-rs 0.0.5

Express.js clone written in your favorite language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use express_rs::Express;

/// This example demonstrates how to access the body of a request.
/// Test it by POSTing a request with any body to port 8080
fn main() {
    let mut app = Express::new();
    app.post("/", |req, res| {
        if let Some(body) = &req.body {
            res.send(body.to_string());
        } else {
            res.send("Nobody here...".to_string());
        }
    });

    let port = 8080;
    println!("Starting server on port {}", port);
    app.listen(port);
}