#http-3 #http2 #server #http1 #http

scuffle-http

A high-performance HTTP server supporting HTTP/1.1, HTTP/2, and HTTP/3

6 releases

0.2.0 Feb 21, 2025
0.1.0 Feb 10, 2025
0.0.5 Feb 9, 2025
0.0.4 Dec 8, 2024
0.0.0 Nov 28, 2024

#165 in HTTP server

Download history 376/week @ 2024-11-27 184/week @ 2024-12-04 120/week @ 2024-12-11 77/week @ 2024-12-18 52/week @ 2024-12-25 153/week @ 2025-01-01 44/week @ 2025-01-08 10/week @ 2025-01-15 4/week @ 2025-01-22 273/week @ 2025-02-05 65/week @ 2025-02-12 158/week @ 2025-02-19 45/week @ 2025-02-26

541 downloads per month
Used in 2 crates

MIT/Apache

120KB
2K SLoC

scuffle-http

[!WARNING]
This crate is under active development and may not be stable.

crates.io docs.rs


An HTTP server with support for HTTP/1, HTTP/2 and HTTP/3.

It abstracts away hyper and h3 to provide a rather simple interface for creating and running a server that can handle all three protocols.

See the examples directory for usage examples.

Why do we need this?

This crate is designed to be a simple and easy to use HTTP server that supports HTTP/1, HTTP/2 and HTTP/3.

Currently, there are simply no other crates that provide support for all three protocols with a unified API. This crate aims to fill that gap.

Feature Flags

  • tower: Enables support for tower services. Enabled by default.
  • http1: Enables support for HTTP/1. Enabled by default.
  • http2: Enables support for HTTP/2. Enabled by default.
  • http3: Enables support for HTTP/3. Disabled by default.
  • tracing: Enables logging with tracing. Disabled by default.
  • tls-rustls: Enables support for TLS with rustls. Disabled by default.
  • http3-tls-rustls: Enables both http3 and tls-rustls features. Disabled by default.

Example

The following example demonstrates how to create a simple HTTP server (without TLS) that responds with "Hello, world!" to all requests on port 3000.

let service = scuffle_http::service::fn_http_service(|req| async move {
    scuffle_http::Response::builder()
        .status(scuffle_http::http::StatusCode::OK)
        .header(scuffle_http::http::header::CONTENT_TYPE, "text/plain")
        .body("Hello, world!".to_string())
});
let service_factory = scuffle_http::service::service_clone_factory(service);

scuffle_http::HttpServer::builder()
    .with_service_factory(service_factory)
    .bind("[::]:3000".parse().unwrap())
    .build()
    .expect("failed to build server")
    .run()
    .await
    .expect("server failed");

Status

This crate is currently under development and is not yet stable.

Missing Features

  • HTTP/3 webtransport support
  • Upgrading to websocket connections from HTTP/3 connections (this is usually done via HTTP/1.1 anyway)

Unit tests are not yet fully implemented. Use at your own risk.

License

This project is licensed under the MIT or Apache-2.0 license. You can choose between one of them if you use this work.

SPDX-License-Identifier: MIT OR Apache-2.0

Dependencies

~5–24MB
~449K SLoC