rs-express 0.1.0

A port of express-js in Rust
Documentation
  • Coverage
  • 20%
    2 out of 10 items documented0 out of 0 items with examples
  • Size
  • Source code size: 56.71 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.24 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 37s Average build duration of successful builds.
  • all releases: 37s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • idan-at

rs-express

rs-express is a simple web framework written in Rust that tries to be as close to Express.js as possible.

The goal of this project is to allow Node.js web developers to easily migrate their web services to Rust, without the hassle of learning a new web framework.

Most APIs will be very similar or even identical to the Node.js version, under the limitations of Rust.

Just to show how similar it can be, here is the Hello World example from express-js github repository:

const express = require('express')
const app = express()

app.get('/', function (req, res) {
  res.send('Hello World')
})

app.listen(3000)

And here is the one in rs-express:

use rs_express::{App, NextFunction, Request, Response};

#[tokio::main]
async fn main() {
    let mut app: App<()> = App::new();

    app.get(
        "/",
        |_req: &mut Request<()>, res: &mut Response, _next: &mut NextFunction| {
            res.send("Hello, World");
        },
    );

    app.listen(3000).await.expect("Failed to listen");
}

Installation

[dependencies]
rs_express = "0.1.0"

Features

  • Familiar API
  • Focus on high performance
  • Simple and easy of use
  • Application level state
  • Simple and robust routing
  • Easy testing capabilities

Also, since it is built on top of hyper, it provides (taken from their README)

  • HTTP/1 and HTTP/2
  • Asynchronous design
  • Leading in performance
  • Tested and correct
  • Extensive production use

Examples

All the examples are under the examples folder.

To run a specific example, run the following command: cargo run --example <example-name>

For example cargo run --example hello-world.

To get a response, use this address: http://localhost:3000 . For example, curl http://localhost:3000/hello will return Hello, World.