Skip to content

Installation

Requirements

Minimum Supported Rust Version (MSRV): 1.75

Install or update Rust via rustup:

Terminal window
rustup update stable
rustc --version # should print 1.75.0 or newer

As a library crate

Add rust-web-server to your Cargo.toml:

Terminal window
cargo add rust-web-server

Or pin the major version manually:

[dependencies]
rust-web-server = "17"

The default feature set (http3) pulls in HTTP/3, HTTP/2, TLS, and a tokio async runtime. If you need a lighter build, opt out and select a lower feature tier (see the feature flags table below).

Prelude

A single glob import covers the types you need in almost every handler:

use rust_web_server::prelude::*;
// Re-exports: App, Server, ConnectionInfo, Request, Response,
// STATUS_CODE_REASON_PHRASE, Range, MimeType,
// PathParams, New, routes!

As a standalone binary

Install the rws binary to ~/.cargo/bin:

Terminal window
cargo install rust-web-server
rws --version

Run it in any directory that contains static files and it will serve them on http://localhost:7878 with no configuration file needed.

Build from source

target/release/rws
git clone https://github.com/bohdaq/rust-web-server.git
cd rust-web-server
cargo build --release

To build a specific feature tier from source:

Terminal window
# HTTP/2 + TLS only (no QUIC)
cargo build --release --no-default-features --features http2
# HTTP/1.1 only — no TLS, no async runtime, smallest binary
cargo build --release --no-default-features --features http1

Feature flags

FeatureWhat it addsRequired deps
http1Synchronous thread-pool server, no async runtime, no TLSctrlc, libc
http2tokio runtime, TLS via rustls (aws-lc-rs), HTTP/2 via ALPNh2, rustls, tokio, tokio-rustls, …
http3 (default)QUIC transport and HTTP/3 on top of http2quinn, h3, h3-quinn
http-clientHTTPS support in the outbound Clientrustls, webpki-roots
serdeJSON serialization/deserialization via serdeserde, serde_json
authHMAC-SHA2 utilities for JWT signing and cookie signinghmac, sha2
macros#[derive(Model)] proc-macro for the ORM layerrws-macros
acmeAutomatic TLS certificate provisioning (ACME/Let’s Encrypt)rcgen, aws-lc-rs, …
teraTera template engine integrationtera, serde, serde_json
model-sqliteORM backend for SQLite (bundled libsqlite3, no system dep)rusqlite
model-postgresORM backend for PostgreSQLpostgres
model-mysqlORM backend for MySQL / MariaDBmysql
cryptoArgon2id password hashingargon2, rand_core
csrfCSRF token generation and validationrand_core
ssoOAuth 2.0 / OIDC SSO support (RSA + ECDSA signing, outbound HTTPS)rsa, p256, sha2, rand_core, serde, serde_json, http-client

Approximate binary sizes

These measurements are for a release build (cargo build --release) of the rws binary with only the core transport feature active. Enabling additional features (serde, tera, ORM backends, etc.) increases the size.

Feature tierApprox. binary size
http1~3 MB
http2~8 MB
http3 (default)~12 MB

No third-party HTTP dependencies

HTTP parsing, CORS, MIME types, range requests, WebSocket, SSE, and routing are all implemented from scratch inside this crate. The transitive dependency tree has no hyper, actix-net, or tokio-util.