Crates.io | actix-delay |
lib.rs | actix-delay |
version | 0.1.0 |
source | src |
created_at | 2020-02-11 05:48:31.807083 |
updated_at | 2020-02-11 05:48:31.807083 |
description | Simulates a delayed response for actix-web |
homepage | https://github.com/kuy/actix-delay |
repository | https://github.com/kuy/actix-delay |
max_upload_size | |
id | 207232 |
size | 42,803 |
This crate provides a middleware of actix-web which simulates a delayed/slow response for testing purpose.
Add actix-delay
to dependencies
section in your project.
[dependencies]
actix-delay = "0.1"
Add actix_delay::middleware::Delay
as middleware.
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.
cargo run --example simple
Yuki Kodama / @kuy