2 releases
0.1.1 | Oct 15, 2023 |
---|---|
0.1.0 | Oct 15, 2023 |
#1141 in HTTP server
19KB
449 lines
Resless Web
Express-inspired rust web framework.
Examples
Minimal http server setup
use restless_web::{app::App, route_handler::RouteHandler};
fn main() {
let port = 8080;
let app = App::new();
app.get("/", |_, mut res| {
res.set("Content-Type", "text/plain");
res.status(200).send("Hello world!")
});
app.listen(port, || println!("[info]: Started HTTP server at {port}"));
}
Accessing request fields
use restless_web::{app::App, route_handler::RouteHandler};
fn main() {
let port = 8069;
let app = App::new();
app.get("/", |req, mut res| {
// NOTE: For more details checkout 'src/request.rs'
println!("req.body={:?}", req.body);
res.set("Content-Type", "text/plain");
res.status(200).send("Goodbye world!")
});
app.listen(port, || println!("[info]: Started HTTP server at {port}"));
}
Dependencies
~4–10MB
~110K SLoC