tower-http

A collection of Tower middleware and utilities for building HTTP clients and servers in Rust

Library
Cargo
v0.7.1
924 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
83 /100 Excellent
Development Activity 84
Maintenance 76
Community 84
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 83
Code Quality 85
Innovation 78
Learning Curve 76

tower-http provides a large collection of ready-made Service/Layer middleware built on the tower ecosystem, covering the HTTP cross-cutting concerns almost every server or client needs: compression and decompression, CORS, request tracing, timeouts, authentication, sensitive-header redaction, request ID propagation, path normalization, and more. Because everything implements Tower’s standard Service/Layer traits, these middlewares compose with any Tower-compatible framework or client — most commonly axum and hyper — via tower::ServiceBuilder.

Rather than each framework reimplementing compression or CORS handling itself, tower-http centralizes these concerns as reusable, independently-versioned building blocks that any Tower-based HTTP stack can opt into per-feature via Cargo feature flags.

What You Get

  • Compression/decompression middleware supporting gzip, brotli, deflate, and zstd
  • CorsLayer for configuring cross-origin resource sharing headers declaratively
  • TraceLayer for structured request/response tracing integrated with the tracing crate
  • Auth-adjacent middleware: RequireAuthorizationLayer, sensitive-header redaction, and CSRF helpers
  • Operational middleware: TimeoutLayer, RequestIdLayer, CatchPanicLayer, path normalization, and metrics hooks
  • Everything implemented as standard Tower Service/Layers, composable via tower::ServiceBuilder with any Tower-compatible framework

Common Use Cases

  • Adding gzip/brotli response compression to an axum or hyper server with a single ServiceBuilder layer
  • Configuring CORS for a Rust API consumed by a browser-based frontend without hand-writing header logic
  • Instrumenting every request/response with structured tracing spans for observability
  • Redacting sensitive headers (Authorization, Cookie) from logs while still tracing requests
  • Adding consistent timeouts, panic recovery, and request-ID propagation across every route in a service

Under The Hood

Architecture — The crate is organized as one middleware family per top-level module under tower-http/src/ — compression/, decompression/, cors/, trace/, auth/, csrf/, follow_redirect/, metrics/, set_header/, timeout/, and standalone files like catch_panic.rs, normalize_path.rs, request_id.rs, and sensitive_headers.rs — each exposing a Layer type that wraps an inner Tower Service. service_ext.rs provides a ServiceBuilderExt trait that adds ergonomic .trace_for_http()/.compression()-style methods directly onto tower::ServiceBuilder, so consumers rarely construct layer types by hand.

Tech Stack — Pure Rust (edition 2018, MSRV 1.65), built directly on the Tower ecosystem: tower-layer/tower-service for the middleware contract, http/bytes for HTTP types, pin-project-lite for safe pinned futures, and bitflags for compact option sets. Nearly every middleware family is gated behind its own Cargo feature flag, so consumers pay compile-time and dependency cost only for the middleware they actually enable.

Code Quality — Each middleware module ships its own focused unit tests colocated with the implementation, plus test-files/ fixtures used by the compression/decompression tests to verify round-tripping across gzip/brotli/deflate/zstd. deny.toml enforces dependency/license auditing via cargo-deny in CI, and the project has sustained very active, well-maintained development (350M+ cumulative downloads, frequent releases) as one of the standard middleware crates for the axum/Tower ecosystem.

API Design — The ServiceBuilderExt trait is the primary ergonomic surface: chaining .layer(CompressionLayer::new()).layer(CorsLayer::permissive()).layer(TraceLayer::new_for_http()) reads as a declarative middleware stack rather than nested wrapper types, and most layers ship sensible ::new() or preset constructors (CorsLayer::permissive()) so getting started requires minimal configuration. Because every middleware follows the same Layer/Service shape, learning one (e.g. CompressionLayer) transfers directly to using any other in the crate.

Used by 15 apps in this directory

Rust
63%
MIT

Readur

Bookmarks Archiving · File Storage · Knowledge Management

804

A self-hosted document management system that OCRs, indexes, and makes every PDF, scan, and Office file instantly searchable.

View details
83
Repo Health
78
Technical
67
Dependency
Built with
Rust 63%
TypeScript 32%
Updated 5 days ago
Python
64%
AGPL 3.0

Shadowbroker

Analytics · Monitoring · Security

11,358

Self-hosted OSINT dashboard that fuses 60+ live intelligence feeds — flight tracking, ship AIS, satellites, CCTV, seismic and radio networks — into one real-time map, with an agent-ready command channel for AI co-analysts.

View details
85
Repo Health
83
Technical
71
Dependency
Built with
Python 64%
TypeScript 32%
Updated 6 days ago
TypeScript
61%
AGPL 3.0

Silex

Design Tools · No Code Platforms

3,015

Free, open-source visual website builder that exports clean HTML/CSS — no lock-in, no subscription, host anywhere

View details
89
Repo Health
68
Technical
67
Dependency
Built with
TypeScript 61%
Rust 15%
JavaScript 11%
Updated 6 days ago
Rust
79%
AGPL 3.0

Spacedrive

Collaboration · File Storage

39,292

One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.

View details
84
Repo Health
84
Technical
63
Dependency
Built with
Rust 79%
TypeScript 18%
Updated 2 weeks ago
Rust
46%
MIT

Svix

Automation · Developer Tools

3,463

Open source, self-hostable webhook infrastructure that handles delivery, retries, HMAC signing, and multi-tenant event management so you never have to build a webhooks system from scratch.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
Rust 46%
C# 16%
Updated 6 days ago
Rust
50%
Apache 2.0

Vibe Kanban

AI Agents · AI Code Assistants · Project Management

28,441

A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.

View details
72
Repo Health
75
Technical
63
Dependency
Built with
Rust 50%
TypeScript 46%
Updated 1 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers