expressrs

Crates.ioexpressrs
lib.rsexpressrs
version0.1.6
sourcesrc
created_at2024-07-03 17:14:02.723622
updated_at2024-07-06 14:22:28.736324
descriptionCreate a website in localhost with ease!
homepage
repository
max_upload_size
id1290770
size25,308
ContentGamer (ContentGamer)

documentation

README

ExpressRS

HTTP Localhosts made with ease!

Ideas

Changelog

  • Plugin support
  • Query parameter parsing
  • URL Decoding

Example

// main.rs

use expressrs::ExpressLib;

fn main() {
    let express = ExpressLib::new();
    let mut app = express();

    // Create a directory called public/ that has index.html and script.js
    app.serve_directory("public");

    app.get("/", |_, res| {
        res.status(200).send_file("public/index.html");
    });

    app.listen(3030, |port| {
        println!("Server listening at http://localhost:{}", port);
    });
}

Query parameters example

// main.rs

use expressrs::ExpressLib;

fn main() {
    let express = ExpressLib::new();
    let mut app = express();

	// This will replace the response IF the query parameter is not found
    app.get("/:user", |_, res| {
		// IS required to be Some() (aka Something)
        println!("{:?}", req.queries.get("user"));
		// Can be None unless it is added to the query parameters
        println!("{:?}", req.queries.get("database"));
    });

    app.listen(3030, |port| {
        println!("Server listening at http://localhost:{}", port);
    });
}

Dependencies

serde_json 1.0

serde { features = ["derive"], version = "1.0" }

Commit count: 0

cargo fmt