mirror of
https://github.com/actix/actix-website
synced 2024-11-23 16:31:08 +01:00
parent
30edc4885d
commit
f786600af3
@ -27,7 +27,7 @@ Alternatively, for simple use cases, you can use [_wrap_fn_][wrap_fn] to create
|
|||||||
|
|
||||||
<CodeBlock example="middleware" file="wrap_fn.rs" section="wrap-fn" />
|
<CodeBlock example="middleware" file="wrap_fn.rs" section="wrap-fn" />
|
||||||
|
|
||||||
You can also use [_from_fn_][from_fn] to in combination with [_wrap_][wrap] to create a function as middlware.
|
You can also use [_from_fn_][from_fn] to in combination with [_wrap_][wrap] to create a function as middleware.
|
||||||
|
|
||||||
<CodeBlock example="middleware" file="from_fn.rs" section="from-fn" />
|
<CodeBlock example="middleware" file="from_fn.rs" section="from-fn" />
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ use actix_web::{
|
|||||||
App, Error,
|
App, Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
async fn my_midleware(
|
async fn my_middleware(
|
||||||
req: ServiceRequest,
|
req: ServiceRequest,
|
||||||
next: Next<impl MessageBody>,
|
next: Next<impl MessageBody>,
|
||||||
) -> Result<ServiceResponse<impl MessageBody>, Error> {
|
) -> Result<ServiceResponse<impl MessageBody>, Error> {
|
||||||
@ -19,6 +19,6 @@ async fn my_midleware(
|
|||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let app = App::new().wrap(from_fn(my_midleware));
|
let app = App::new().wrap(from_fn(my_middleware));
|
||||||
}
|
}
|
||||||
// </from-fn>
|
// </from-fn>
|
||||||
|
Loading…
Reference in New Issue
Block a user