mirror of
https://github.com/actix/actix-website
synced 2025-02-02 12:19:04 +01:00
23 lines
561 B
Rust
23 lines
561 B
Rust
#![allow(dead_code, unused_variables)]
|
|
|
|
// <wrap-fn>
|
|
use actix_web::{dev::Service as _, web, App};
|
|
use futures_util::future::FutureExt;
|
|
|
|
#[actix_web::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>
|