Crates.io | rouille-ng |
lib.rs | rouille-ng |
version | 3.0.1 |
source | src |
created_at | 2021-04-12 08:59:26.169002 |
updated_at | 2021-04-12 09:41:19.69595 |
description | High-level idiomatic web framework. |
homepage | |
repository | https://github.com/bradfier/rouille-ng |
max_upload_size | |
id | 382301 |
size | 359,995 |
rouille-ng is a maintenance fork of Rouille,
Rouille is a micro-web-framework library. It creates a listening socket and parses incoming HTTP requests from clients, then gives you the hand to process the request.
Rouille was designed to be intuitive to use if you know Rust. Contrary to express-like frameworks, it doesn't employ middlewares. Instead everything is handled in a linear way.
Concepts closely related to websites (like cookies, CGI, form input, etc.) are directly supported by rouille. More general concepts (like database handling or templating) are not directly handled, as they are considered orthogonal to the micro web framework. However rouille's design makes it easy to use in conjunction with any third-party library without the need for any glue code.
The original Rouille project has been unmaintained for over a year, and it seems unlikely to become active again soon. Rouille NG is intended to support teams using Rouille in production with security fixes and quality of life improvements, while retaining API compatibility with the original library.
Community contributions in line with these goals are welcome!
If you have general knowledge about how HTTP works, the documentation and the well-documented examples are good resources to get you started.
You can swap your dependency on Rouille for Rouille NG by adding the following to your Cargo.toml
[dependencies]
rouille = { package = "rouille-ng", version = "3" }
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.
Async I/O, green threads, coroutines, etc. in Rust are still very immature.
The rouille library just ignores this optimization and focuses on providing an easy-to-use synchronous API instead, where each request is handled in its own dedicated thread.
Even if rouille itself was asynchronous, you would need asynchronous database clients and asynchronous file loading in order to take advantage of it. There are currently no such libraries in the Rust ecosystem.
Once async I/O has been figured out, rouille will be (hopefully transparently) updated to take it into account.
On the author's old Linux machine, some basic benchmarking with wrk -t 4 -c 4
shows the
following results:
http.createServer
) yields ~14k requests/sec.While not the fastest, rouille has reasonable performances. Amongst all these examples, rouille is the only one to use synchronous I/O.
It should be trivial to integrate a database or templates to your web server written with rouille. Moreover plugins need maintenance and tend to create a dependency hell. In the author's opinion it is generally better not to use plugins.
Instead of doing this: (pseudo-code)
server.add_middleware(function() {
// middleware 1
});
server.add_middleware(function() {
// middleware 2
});
server.add_middleware(function() {
// middleware 3
});
In rouille you just handle each request entirely manually:
// initialize everything here
rouille::start_server(..., move |request| {
// middleware 1
// middleware 2
// middleware 3
});