monoio-relay is a high-performance, easy-to-use HTTP server framework written in Rust. Built on the monoio runtime and its io_uring driver, the framework offers minimal overhead for performance-critical applications.
- Support for all HTTP methods: Handles all 9 standard HTTP methods with ease.
- Static routes: Efficiently manage predefined routes.
- Dynamic pattern matching:
- Utilize a combination of LRU cache and radix trees for pattern matching.
- Supports placeholders and wildcard patterns.
- Nested routes: Easily organize and process nested route hierarchies.
- Layered services architecture:
- Stack service layers as needed, built with flexible service factories.
- Unified server configuration simplifies layer management.
- Thanks to service-async: which enables integration of various service layers.
- Fully customizable parameters for server initialization using the
hyperbuilder API.
- Rate limiting: Control and manage request throughput to ensure system stability.
- Router state app: Share data across routes with the Router State App (just remember your state type needs to implement Clone!)
- Secure Communication: TLS is supported via Rustls for secure connections
- Request Validation: Validate request headers and query parameters
- Metrics: Track cache performance metrics whichever layer uses a cache (gated behind the 'metrics' feature)
Each handler function in monoio-relay takes only two mandatory parameters:
- Request: Represents the incoming HTTP request.
- State: Access the user-defined application state.
use monoio_relay::router::AppState;
// Note: The state application must implement the `Clone` trait. Check examples
// If you don't want to specify any stateful app
async fn sample_request_handler(_req: Request<HttpBody>, _state: AppState<()>) -> Response<HyperBody> {
Response::new(HyperBody::text("Hello from /api/users route"))
}
// If you want to provide and use the state
async fn sample_request_handler(req: Request<HttpBody>, state: AppState<YourStateApp>) -> Response<HyperBody> {
Response::new(HyperBody::text("Hello from /api/users route"))
}please refer examples for more implementation details
benchmarked using wrk and rewrk against other popular Rust frameworks. A simple "Hello, World!" HTTP server was used for raw performance evaluation.
- Incoming request logging.
- Request/response compression for improved performance.
- Authentication mechanisms.