1
0
mirror of https://github.com/actix/actix-website synced 2024-11-25 01:02:58 +01:00
actix-website/examples/middleware/src/wrap_fn.rs
2019-12-29 02:03:17 +09:00

24 lines
552 B
Rust

// <wrap-fn>
use actix_service::Service;
use actix_web::{web, App};
use futures::future::FutureExt;
#[actix_rt::main]
async fn main() {
let app = App::new()
.wrap_fn(|req, srv| {
println!("Hi from start. You requested: {}", req.path());
srv.call(req).map(|res| {
println!("Hi from response");
res
})
})
.route(
"/index.html",
web::get().to(|| async {
"Hello, middleware!"
}),
);
}
// </wrap-fn>