An open API service indexing awesome lists of open source software.

https://github.com/kuy/actix-delay

Simulates a delayed response for actix-web
https://github.com/kuy/actix-delay

actix actix-web middleware rust testing

Last synced: about 2 months ago
JSON representation

Simulates a delayed response for actix-web

Awesome Lists containing this project

README

        

# actix-delay

[![crates.io](https://img.shields.io/crates/v/actix-delay.svg)](https://crates.io/crates/actix-delay)
[![build](https://github.com/kuy/actix-delay/workflows/build/badge.svg)](https://github.com/kuy/actix-delay/actions)

This crate provides a middleware of [actix-web](https://actix.rs/) which simulates a delayed/slow response for testing purpose.

## Usage

Add `actix-delay` to `dependencies` section in your project.

```toml
[dependencies]
actix-delay = "0.1"
```

Add `actix_delay::middleware::Delay` as middleware.

```rust
use actix_delay::middleware::Delay;

async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.wrap(Delay::new(3000))
.service(resource("/").to(|| async { "Hello!" }))
})
.bind("127.0.0.1:8080")?
.run()
.await
}
```

See [full example](https://github.com/kuy/actix-delay/blob/master/examples/simple.rs).

## Examples

- [simple](https://github.com/kuy/actix-delay/blob/master/examples/simple.rs): `cargo run --example simple`

## License

[MIT](https://github.com/kuy/actix-delay/blob/master/LICENSE)

## Author

Yuki Kodama / [@kuy](https://twitter.com/kuy)