Routerify-NG
Routerify-NG (Next Generation) is a modern, lightweight, idiomatic, and modular router for the Rust HTTP library Hyper 1.x.
Itβs a maintained and upgraded fork of the original Routerify rewritten for the new Hyper service model.
β¨ Highlights
- π Build complex routing with scopes and middlewares
- βοΈ Fully compatible with Hyper 1.x and Tokio 1.x
- π Fast route matching via
RegexSet - π§© Middleware system with shared state between routes
- π¬ Robust error handling
- π
WebSocketsupport (compatible with Hyper 1.x) - π Extensive documentation and examples
β‘ Benchmarks
| Framework | Language | Requests/sec |
|---|---|---|
| Hyper 1.7 | Rust 2024 | 160 000 + |
| Routerify-NG (Hyper 1.7) | Rust 2024 | 158 000 + |
| Actix-Web 4 | Rust 2024 | 150 000 + |
| Warp 0.3 | Rust 2024 | 145 000 + |
(benchmarks vary per system; see benchmarks folder)
Install
Add this to your Cargo.toml:
[]
= "0.1.0"
= "1.7"
= { = "1", = ["full"] }
Example
use Full;
use Incoming;
use Service;
use ;
use TokioExecutor;
use TokioIo;
use Builder;
// Import the routerify prelude traits.
use *;
use ;
use Arc;
use ;
use TcpListener;
// Define an app state to share it across the route handlers and middlewares.
;
// A handler for "/" page.
async
// A handler for "/users/:userId" page.
async
// A middleware which logs an http request.
async
// Define an error handler function which will accept the `routerify::Error`
// and the request information and generates an appropriate response.
async
// Create a `Router<Body, Infallible>` for response body type `hyper::Body`
// and for handler error type `Infallible`.
async
Documentation
Docs for an exhaustive documentation.
Examples
Find runnable examples in the examples directory.
Contributing
PRs, ideas, and suggestions are always welcome!
If youβd like to help maintain Routerify-NG or extend its ecosystem (WebSockets, tower integration, macros, etc.), open an issue or pull request.
License
Licensed under the MIT License.
Routerify-NG β keeping Hyper simple, fast, and modern for the next generation of Rust web developers.