• Stars
    star
    1,087
  • Rank 42,594 (Top 0.9 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Web framework in Rust

Rouille, a Rust web micro-framework

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.

Documentation

Getting started

If you have general knowledge about how HTTP works, the documentation and the well-documented examples are good resources to get you started.

License

Licensed under either of

Contribution

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.

FAQ

What about performances?

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.

But is it fast?

On the author's old Linux machine, some basic benchmarking with wrk -t 4 -c 4 shows the following results:

  • The hello-world example of rouille yields ~22k requests/sec.
  • A hello world in nodejs (with http.createServer) yields ~14k requests/sec.
  • The hello-world example of tokio-minihttp (which is supposedly the fastest HTTP server that currently exists) yields ~77k requests/sec.
  • The hello example of hyper (which uses async I/O with mio as well) yields ~53k requests/sec.
  • A hello world in Go yields ~51k requests/sec.
  • The default installation of nginx yields ~39k requests/sec.

While not the fastest, rouille has reasonable performances. Amongst all these examples, rouille is the only one to use synchronous I/O.

Are there plugins for features such as database connection, templating, etc.

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.

But I'm used to express-like frameworks!

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

More Repositories

1

redshirt

🧑‍🔬 Operating system
Rust
1,424
star
2

hlua

Rust library to interface with Lua
C
492
star
3

luawrapper

Easy-to-use lua wrapper for C++
C++
98
star
4

wasm-timer

Abstraction over std::time::Instant and tokio_timer that works on WASM
Rust
72
star
5

glium_text

Text rendering with glium
Rust
47
star
6

immi

Immediate mode library in Rust
Rust
32
star
7

spine-rs

Spine loader in Rust
Rust
32
star
8

futures-diagnose

Wraps around a futures::task::Spawn and adds diagnostics to it
Rust
29
star
9

cargo-emscripten

Experiments with Rust and Emscripten
Rust
19
star
10

shared_library

Rust
18
star
11

vorbis-rs

Rust bindings for libvorbis
Rust
15
star
12

mantle-demo

Rust mantle experiments
Rust
14
star
13

rustfest-2018-workshop

Rust
13
star
14

substrate-browser-node-demo

Small demo of a Substrate node running in the browser
JavaScript
13
star
15

resources_package

Package files in your executables with the Rust language
Rust
12
star
16

from_json

Alternative to the Rust standard Json decoder
Rust
10
star
17

substrate-tetris

Tetris built on Substrate
Rust
9
star
18

rust-mingw-docker

🐳 Docker image with Rust configured for x86_64-pc-windows-gnu and i686-pc-windows-gnu
Dockerfile
6
star
19

rustc-emscripten

🐳 Docker image with rustup, rust, cargo, and emscripten
Dockerfile
6
star
20

eui

Easy UI
Rust
6
star
21

2018-rustrush-demo

Demo for the RustRush conference
Rust
5
star
22

glium2

5
star
23

clock_ticks

Rust
5
star
24

example-tiny-http

Example of web server in Rust
Rust
5
star
25

glium-azdo

Approaching zero driver overhead with glium
Rust
5
star
26

mick-jaeger

Rust client for OpenTelemetry, specifically for Jaeger
Rust
5
star
27

ogg-sys

Rust bindings for libogg
C
4
star
28

pocket-resources

Rust
4
star
29

glslang-rs

Interface for the `glslang` library in Rust. Allows you to test your shaders at compile-time.
Rust
4
star
30

rust-templates

Proof of concept: Rust compile-time templates
Rust
4
star
31

rust-android-docker

Docker file for a quick Rust + Android environment
4
star
32

glsl_parser

GLSL parser for Rust
Rust
4
star
33

rust-to-glsl

Rust
3
star
34

corooteen

Rust
3
star
35

vorbis-sys

libvorbis bindings for Rust
Rust
3
star
36

cmake-rs

Easily build projets using CMake with the Rust compiler
Rust
3
star
37

2019-rustlatam-meetup

HTML
3
star
38

polkadot-events

Polkadot events scraper
Rust
3
star
39

rustfest-2017-slides

HTML
3
star
40

xrb

XCB in Rust
Rust
3
star
41

zksummit-20180323-libp2p

Slides for the zkSummit conference about libp2p
HTML
2
star
42

wrrm

"Write-rarely-read-many" container
Rust
2
star
43

wasm-abi-test

Rust
2
star
44

declmagic

Game engine written in Rust with declarative programming mind
Rust
2
star
45

cargo-web

Docker image with cargo web installed
Dockerfile
2
star
46

scoped_tasks_future

Rust
2
star
47

parity-alpine

Parity client running on alpine
2
star
48

flate3

flate2 in pure Rust
Rust
2
star
49

rust-ids-container

Rust container which automatically assigns keys when you insert in it
Rust
1
star
50

glium_voxel

Rust
1
star
51

tomaka.github.io

1
star
52

crates-autodoc

Rust
1
star
53

arduino-leds

Rust
1
star
54

heroku-buildpack-rustc

Buildpack that installs rustc on the system to be used at runtime
Shell
1
star
55

cargo-bug-repro-20200624

Rust
1
star
56

tomaka

1
star
57

rustc-issue-repro

Rust
1
star
58

ui-rs

Rust
1
star
59

web-framework-example

Rust
1
star
60

ole32-sys

Rust bindings to ole32
Rust
1
star
61

lua-sys-rs

1
star
62

advapi32-sys

Rust bindings to advapi32
Rust
1
star
63

rust-arm-linux

Dockerfile
1
star
64

libp2pconf-2018-07-slides

Slides for the state of Rust libp2p
HTML
1
star
65

osmesa-rs

Off-Screen Mesa bindings for Rust
Rust
1
star
66

niysu

Light and easy to use PHP framework
PHP
1
star
67

glutin_window

A Piston window back-end using the Glutin library
Rust
1
star
68

spec

1
star
69

text-render-atlas

Rust
1
star
70

web-framework

Rust
1
star
71

frp-rs

Functional Reactive Programming - Rust
Rust
1
star
72

vorbisfile-sys

Rust bindings for libvorbisfile
C
1
star
73

test-browser-node

JavaScript
1
star