1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

refactor: switch from_fn to stable version

This commit is contained in:
Rob Ede
2024-09-11 10:31:11 -04:00
parent 431ebe8c2b
commit e962a2a9b1
4 changed files with 11 additions and 10 deletions

View File

@ -33,4 +33,4 @@ A minimal middleware demonstrating the sequence of operations in an actix middle
## See Also
- The `from_fn` middleware constructor from [`actix-web-lab`](https://crates.io/crates/actix-web-lab).
- The [`from_fn` middleware constructor](https://docs.rs/actix-web/4/actix_web/middleware/fn.from_fn.html).

View File

@ -1,16 +1,18 @@
use std::time::Duration;
use actix_http::body::MessageBody;
use actix_web::{dev, rt::time, web, App, Error, HttpServer};
use actix_web_lab::middleware::{from_fn, Next};
use actix_web::{
body::MessageBody,
dev,
middleware::{from_fn, Next},
rt::time,
web, App, Error, HttpServer,
};
mod read_request_body;
mod read_response_body;
mod redirect;
mod simple;
// See more examples of from_fn middleware here:
// https://github.com/robjtede/actix-web-lab/blob/main/actix-web-lab/examples/from_fn.rs
async fn timeout_10secs(
req: dev::ServiceRequest,
next: Next<impl MessageBody + 'static>,