monoio-relay

Crates.iomonoio-relay
lib.rsmonoio-relay
version0.1.0
created_at2025-12-08 07:00:47.454566+00
updated_at2025-12-08 07:00:47.454566+00
descriptionmonoio-relay is a high-performance, easy-to-use HTTP server framework built for use with the Monoio runtime
homepage
repositoryhttps://github.com/ReflxzR/monoio-relay
max_upload_size
id1972848
size165,412
Priyanshu Singh (ReflxzR)

documentation

README

monoio-relay

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.

Key Features

Routing

  • 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.

Modular Design

  • 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.

Server Configuration

  • Fully customizable parameters for server initialization using the hyper builder API.

Additional Capabilities

  • 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)

Handler Function Simplicity

Each handler function in monoio-relay takes only two mandatory parameters:

  1. Request: Represents the incoming HTTP request.
  2. 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

Benchmark Performance

benchmarked using wrk and rewrk against other popular Rust frameworks. A simple "Hello, World!" HTTP server was used for raw performance evaluation.

Planned Features (Work in Progress)

  • Incoming request logging.
  • Request/response compression for improved performance.
  • Authentication mechanisms.
Commit count: 0

cargo fmt