mirror of
https://github.com/actix/actix-website
synced 2025-02-02 04:09:06 +01:00
f786600af3
* fix typo * fix another typo
25 lines
510 B
Rust
25 lines
510 B
Rust
#![allow(dead_code, unused_variables)]
|
|
|
|
// <from-fn>
|
|
use actix_web::{
|
|
body::MessageBody,
|
|
dev::{ServiceRequest, ServiceResponse},
|
|
middleware::{from_fn, Next},
|
|
App, Error,
|
|
};
|
|
|
|
async fn my_middleware(
|
|
req: ServiceRequest,
|
|
next: Next<impl MessageBody>,
|
|
) -> Result<ServiceResponse<impl MessageBody>, Error> {
|
|
// pre-processing
|
|
next.call(req).await
|
|
// post-processing
|
|
}
|
|
|
|
#[actix_web::main]
|
|
async fn main() {
|
|
let app = App::new().wrap(from_fn(my_middleware));
|
|
}
|
|
// </from-fn>
|