1 unstable release

0.1.0 Feb 11, 2020

#28 in #actix-web-middleware

MIT license

13KB
69 lines

actix-delay

crates.io build

This crate provides a middleware of actix-web which simulates a delayed/slow response for testing purpose.

Usage

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.

Examples

  • simple: cargo run --example simple

License

MIT

Author

Yuki Kodama / @kuy

Dependencies

~28MB
~583K SLoC