#rate-limiting #governor #actix

actix-governor

A rate-limiting middleware for actix-web backed by the governor crate

20 releases

0.10.0 Oct 12, 2025
0.8.0 Dec 12, 2024
0.7.0 Oct 25, 2024
0.5.0 Oct 4, 2023
0.2.3 Dec 31, 2020

#33 in HTTP server

Download history 7621/week @ 2026-02-16 9501/week @ 2026-02-23 9409/week @ 2026-03-02 9878/week @ 2026-03-09 10229/week @ 2026-03-16 10374/week @ 2026-03-23 9837/week @ 2026-03-30 8645/week @ 2026-04-06 11018/week @ 2026-04-13 14692/week @ 2026-04-20 11340/week @ 2026-04-27 15288/week @ 2026-05-04 13476/week @ 2026-05-11 16178/week @ 2026-05-18 10223/week @ 2026-05-25 9422/week @ 2026-06-01

50,472 downloads per month
Used in 24 crates (22 directly)

GPL-3.0-or-later

93KB
2K SLoC

CI Docs crates.io

Actix Governor

A middleware for actix-web that provides rate-limiting backed by governor.

Features:

  • Simple to use
  • High customizability
  • High performance
  • Robust yet flexible API

Example

use actix_governor::{Governor, GovernorConfigBuilder};
use actix_web::{web, App, HttpServer, Responder};

async fn index() -> impl Responder {
    "Hello world!"
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    // Allow bursts with up to five requests per IP address
    // and replenishes two elements per second
    let governor_conf = GovernorConfigBuilder::default()
        .requests_per_second(2)
        .burst_size(5)
        .finish()
        .unwrap();

    HttpServer::new(move || {
        App::new()
            // Enable Governor middleware
            .wrap(Governor::new(&governor_conf))
            // Route hello world service
            .route("/", web::get().to(index))
    })
    .bind("127.0.0.1:8080")?
    .run()
    .await
}

Add this to your Cargo.toml:

[dependencies]
actix-governor = "0.6"

Dependencies

~21–37MB
~523K SLoC