Skip to content

Build fast. Ship zero deps.

HTTP/1.1 · HTTP/2 · HTTP/3/QUIC · TLS · Reverse Proxy · MCP Server · ORM. One Rust crate. No third-party HTTP dependencies.
HTTP/1.1HTTP/2HTTP/3 / QUICTLS (rustls)CORSGzipETagWebSocketSSE

What’s inside

Zero HTTP dependencies

HTTP parsing, CORS, MIME types, range requests, WebSocket, SSE, and routing are all implemented from scratch — no hyper, no actix-net, no tokio-util.

Config-driven proxy

Drop an rws.config.toml next to the binary and it becomes a reverse proxy, load balancer, and API gateway. No code required.

MCP Server

Expose tools, resources, and prompts to Claude and other AI agents over the MCP Streamable HTTP protocol with a simple builder API.

Middleware pipeline

Compose RateLimitLayer, CacheLayer, OtelLayer, JwtLayer, RewriteLayer, BasicAuthLayer, and more via .wrap(layer).

Model layer ORM

JPA-style ORM with #[derive(Model)], a type-safe QueryBuilder, repository pattern, migrations, and HasMany / HasOne / BelongsTo relations — SQLite, PostgreSQL, or MySQL.

Kubernetes-ready

/healthz, /readyz, /metrics. Graceful SIGTERM shutdown. Prometheus-compatible scrape endpoint. First-class Kubernetes Ingress Watcher.

Prometheus metrics

Server-wide counters plus per-route rws_route_requests_total and rws_route_duration_seconds histograms via MetricsLayer.

WebSocket & SSE

RFC 6455 WebSocket handshake and frame codec built in. Sse builder for Server-Sent Events — ideal for streaming AI tokens.

In-process test client

TestClient::new(App::new()) dispatches requests through your Application without opening a TCP socket — fast, hermetic unit tests with zero infra.

Dependency injection

Container is a TypeId-keyed service store for concrete types and trait objects. Pair with App::with_state(Arc::new(container)) for ergonomic DI.

Background scheduler

Run tasks on a fixed interval, after a delay, or a cron schedule via Scheduler::new().every(…, fn).cron("0 * * * * *", fn).start().

No OpenSSL

TLS is powered by rustls with the aws-lc-rs crypto backend — no system OpenSSL dependency, fully static binaries, FIPS-compatible.

Get started in 60 seconds

As a library

Cargo.toml
[dependencies]
rust-web-server = "17"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
src/main.rs
use rust_web_server::prelude::*;
fn hello(_: &Request, _: &PathParams, _: &ConnectionInfo, _: &()) -> Response {
Response::get_response(
STATUS_CODE_REASON_PHRASE.n200_ok,
None,
Some(vec![Range::get_content_range(
b"Hello, world!".to_vec(),
MimeType::TEXT_PLAIN.to_string(),
)]),
)
}
#[tokio::main]
async fn main() {
let app = routes! {
App::with_state(()),
GET "/hello" => hello,
};
let (listener, pool) = Server::setup().unwrap();
tokio::join!(
Server::run_tls(listener, pool, app.clone()),
Server::run_quic(app),
Server::run_redirect(),
);
}
Terminal window
$ curl http://localhost:7878/hello
Hello, world!

As a proxy — no code required

rws.config.toml
[server]
port = 8080
[[upstream]]
name = "api"
backends = ["localhost:3000", "localhost:3001"]
[upstream.health_check]
path = "/healthz"
interval_secs = 10
healthy_threshold = 2
[[route]]
[route.match]
path = "/api/"
[route.action]
type = "proxy"
upstream = "api"
[[route]]
[route.match]
path = "/"
[route.action]
type = "respond"
status = 200
body = "Gateway ready"
Terminal window
$ rws
Listening on 0.0.0.0:8080

Build matrix

http1http2http3 (default)
Runtimesync thread pooltokiotokio
TLSrustlsrustls
HTTP/2ALPNALPN
QUICquinn
Approx. binary~3 MB~8 MB~12 MB
MSRV1.751.751.75