http-handle 0.0.4

A fast and lightweight Rust library for handling HTTP requests and responses.
Documentation

HTTP Handle (http-handle)

A Rust-based HTTP server for serving static websites.

Made With Love Crates.io lib.rs Docs.rs Codecov Build Status GitHub

WebsiteDocumentationReport BugRequest FeatureContributing Guidelines

Architectural Overview

Use http-handle to serve static content fast, then scale to production policies without rewriting your core server path.

Follow this critical path:

  1. Build and configure a server (Server / ServerBuilder).
  2. Parse incoming HTTP requests into typed request data.
  3. Generate and emit policy-aware HTTP responses.

Feature List

  • Core Serving: Static file routing, MIME detection, custom 404 pages, and request/response primitives.
  • Operational Safety: Directory traversal protection, graceful shutdown, and configurable timeout handling.
  • Performance Paths: Sync + async serving, precompressed asset negotiation (br / gzip / zstd), and high-performance runtime mode.
  • Protocol Growth: HTTP/2 support and HTTP/3 profile/fallback policy primitives.
  • Enterprise Controls: TLS/mTLS policy, API key/JWT auth hooks, RBAC/ABAC adapters, and runtime config reload patterns.
  • Scale Features: Distributed rate limiting, tenant isolation, observability hooks, and runtime auto-tuning.

Platform Support Matrix

http-handle is validated with portability conformance tests and CI coverage across Unix-like targets.

Platform Status Notes
macOS Supported Primary development workflow and CI coverage.
Linux Supported Production target for deployments and containers (validated on Ubuntu CI; Debian-compatible runtime assumptions).
Windows (MSVC) Supported Tier-1 target in the portability policy and CI matrix.
WSL (Windows Subsystem for Linux) Supported Uses Linux target behavior in WSL runtime.

Installation

Add this to your Cargo.toml:

[dependencies]
http-handle = "0.0.4"

Minimum supported Rust version (MSRV): 1.88.0.

Quick Start

Start with Server::new. Move to ServerBuilder when you need explicit policy controls.

use http_handle::Server;

fn main() -> std::io::Result<()> {
    let server = Server::new("127.0.0.1:8080", "./public");
    server.start()
}

The server listens on 127.0.0.1:8080 and serves files from ./public.

Documentation

Primary API docs: docs.rs/http-handle
GitHub Pages mirror: https://sebastienrousseau.github.io/http-handle/

Local docs rendering (with docs.rs feature-gate badges):

RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --open --all-features

Supporting docs:

Release Publication

crates.io publishing is tag-driven. After merge to main, publish by pushing a v* tag (for example v0.0.4) or by manually running the publish workflow.

Examples

Run any example:

cargo run --example example_name

Start with these examples:

  • server_example: Build a server and serve a document root.
  • server_builder_example: Apply headers, CORS, and timeout policies.
  • feature_async_server: Run the async accept path.
  • feature_http2_server: Start the HTTP/2 path behind the http2 feature.
  • feature_enterprise_authorization: Enforce RBAC authorization for an HTTP request.
  • feature_runtime_autotune: Derive runtime limits from host profile.

Examples index: docs/EXAMPLES.md.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the GNU Affero General Public License v3.0.

Acknowledgements

Special thanks to all contributors who have helped build the http-handle library.