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
- Host: GitHub
- URL: https://github.com/kuy/actix-delay
- Owner: kuy
- License: mit
- Created: 2020-02-11T05:27:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-11T06:01:02.000Z (over 5 years ago)
- Last Synced: 2024-10-19T14:03:06.499Z (8 months ago)
- Topics: actix, actix-web, middleware, rust, testing
- Language: Rust
- Size: 5.86 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# actix-delay
[](https://crates.io/crates/actix-delay)
[](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)