2019-07-30 19:03:55 +02:00
|
|
|
// <wrap-fn>
|
|
|
|
use actix_service::Service;
|
|
|
|
use actix_web::{web, App};
|
2019-12-28 18:03:17 +01:00
|
|
|
use futures::future::FutureExt;
|
2019-07-30 19:03:55 +02:00
|
|
|
|
2019-12-28 18:03:17 +01:00
|
|
|
#[actix_rt::main]
|
|
|
|
async fn main() {
|
2019-07-30 19:03:55 +02:00
|
|
|
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",
|
2019-12-28 18:03:17 +01:00
|
|
|
web::get().to(|| async {
|
|
|
|
"Hello, middleware!"
|
|
|
|
}),
|
2019-07-30 19:03:55 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
// </wrap-fn>
|