Skip to content

Commit

Permalink
Add imports to code example in README (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMoolenaar authored Jan 14, 2024
1 parent 9caef52 commit eda8261
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ Allows for:
## Getting Started

```rust
use actix_web::{App, HttpServer};
use actix_extensible_rate_limit::{
backend::{memory::InMemoryBackend, SimpleInputFunctionBuilder},
RateLimiter,
};
use std::time::Duration;

#[actix_web::main]
async fn main() -> std::io::Result<()> {
// A backend is responsible for storing rate limit data, and choosing whether to allow/deny requests
let backend = InMemoryBackend::builder().build();

HttpServer::new(move || {
// Assign a limit of 5 requests per minute per client ip address
let input = SimpleInputFunctionBuilder::new(Duration::from_secs(60), 5)
Expand Down

0 comments on commit eda8261

Please sign in to comment.