1
0
mirror of https://github.com/actix/actix-website synced 2025-06-27 07:29:02 +02:00

Add bit about wrap_fn to middlewares page (#104)

This commit is contained in:
Sven-Hendrik Haase
2019-07-30 19:03:55 +02:00
committed by Nikolay Kim
parent 16b8702252
commit a7c8116fcd
3 changed files with 26 additions and 0 deletions

View File

@ -2,6 +2,7 @@ pub mod default_headers;
pub mod errorhandler;
pub mod logger;
pub mod user_sessions;
pub mod wrap_fn;
// <simple>
use actix_service::{Service, Transform};

View File

@ -0,0 +1,20 @@
// <wrap-fn>
use actix_service::Service;
use actix_web::{web, App};
use futures::future::Future;
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(|| "Hello, middleware!"),
);
}
// </wrap-fn>