Which Rust web framework to choose in 2022 (with code examples)

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • hyper

    An HTTP library for Rust (by hyperium)

  • My heart goes to axum. I find it has the cleanest API, it is built on top of hyper, which is (certainly) the most tested and reliable HTTP stack in Rust, and because it is developed by tokio's team.

  • Tide

    Fast and friendly HTTP server framework for async Rust

  • tide

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • Rouille, Rust web server middleware

    Web framework in Rust (by tomaka)

  • rouille

  • Iron

    An Extensible, Concurrent Web Framework for Rust

  • iron

  • tower

    async fn(Request) -> Result<Response, Error>

  • #[derive(Clone)] struct MyMiddleware { inner: S, } impl Service> for MyMiddleware where S: Service, Response = Response> + Clone + Send + 'static, S::Future: Send + 'static, { type Response = S::Response; type Error = S::Error; type Future = BoxFuture<'static, Result>; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { self.inner.poll_ready(cx) } fn call(&mut self, mut req: Request) -> Self::Future { println!("before"); // best practice is to clone the inner service like this // see https://github.com/tower-rs/tower/issues/547 for details let clone = self.inner.clone(); let mut inner = std::mem::replace(&mut self.inner, clone); Box::pin(async move { let res: Response = inner.call(req).await?; println!("after"); Ok(res) }) } } fn main() { let app = Router::new() .route("/", get(|| async { /* ... */ })) .layer(layer_fn(|inner| MyMiddleware { inner })); }

  • bloom

    The simplest way to de-Google your life and business: Inbox, Calendar, Files, Contacts & much more (by skerkour)

  • For larger projects, I think that actix-web is the incontestable winner. That's why it's my choice for Bloom.

  • black-hat-rust

    Applied offensive security with Rust - https://kerkour.com/black-hat-rust

  • Want to learn Rust, Cybersecurity and applied Cryptography? Take a look at my book Black Hat Rust!

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts