1
0
mirror of https://github.com/actix/actix-website synced 2025-02-13 16:42:21 +01:00

26 lines
593 B
Rust
Raw Normal View History

2020-09-12 16:21:54 +01:00
#![allow(dead_code, unused_variables)]
// <wrap-fn>
use actix_service::Service;
use actix_web::{web, App};
2019-12-29 02:03:17 +09:00
use futures::future::FutureExt;
2020-09-12 16:21:54 +01:00
#[actix_web::main]
2019-12-29 02:03:17 +09:00
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",
2019-12-29 02:03:17 +09:00
web::get().to(|| async {
"Hello, middleware!"
}),
);
}
// </wrap-fn>