restless-web

Crates.iorestless-web
lib.rsrestless-web
version0.1.1
sourcesrc
created_at2023-10-15 06:17:57.599144
updated_at2023-10-15 09:32:41.880939
descriptionBack-end framework inspired by express.js
homepagehttps://github.com/restless-rs/restless
repository
max_upload_size
id1003519
size18,433
Egor (gregor-tokarev)

documentation

README

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}"));
}

Commit count: 0

cargo fmt