Crates.io | restless-web |
lib.rs | restless-web |
version | 0.1.1 |
source | src |
created_at | 2023-10-15 06:17:57.599144 |
updated_at | 2023-10-15 09:32:41.880939 |
description | Back-end framework inspired by express.js |
homepage | https://github.com/restless-rs/restless |
repository | |
max_upload_size | |
id | 1003519 |
size | 18,433 |
Express-inspired rust web framework.
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}"));
}