2020-09-12 16:21:54 +01:00
|
|
|
#![allow(dead_code, unused_variables)]
|
|
|
|
|
2019-07-30 19:03:55 +02:00
|
|
|
// <wrap-fn>
|
2022-02-26 03:56:24 +00:00
|
|
|
use actix_web::{dev::Service as _, web, App};
|
|
|
|
use futures_util::future::FutureExt;
|
2019-07-30 19:03:55 +02:00
|
|
|
|
2020-09-12 16:21:54 +01:00
|
|
|
#[actix_web::main]
|
2019-12-29 02:03:17 +09:00
|
|
|
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",
|
2022-02-26 03:56:24 +00:00
|
|
|
web::get().to(|| async { "Hello, middleware!" }),
|
2019-07-30 19:03:55 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
// </wrap-fn>
|