pub fn wrap_fn<F, R>(
        self,
        mw: F,
    ) -> NormalizedResource<
        impl NewService<
            Config = (),
            Request = ServiceRequest,
            Response = ServiceResponse,
            Error = Error,
            InitError = (),
        >,
    >
    where
        F: FnMut(ServiceRequest, &mut T::Service) -> R + Clone,
        R: IntoFuture<Item = ServiceResponse, Error = Error>,
    {
        self.wrap(mw)
    }
/// Register a resource middleware function.
///
/// This function accepts instance of `ServiceRequest` type and
/// mutable reference to the next middleware in chain.
///
/// This is similar to `App's` middlewares, but middleware get invoked on resource level.
/// Resource level middlewares are not allowed to change response
/// type (i.e modify response's body).
///
/// ```rust
/// use actix_service::Service;
/// # use futures::Future;
/// use actix_web::{web, App};
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue};
///
/// fn index() -> &'static str {
///     "Welcome!"
/// }
///
/// fn main() {
///     let app = App::new().service(
///         web::normalized_resource("/index.html")
///             .wrap_fn(|req, srv|
///                 srv.call(req).map(|mut res| {
///                     res.headers_mut().insert(
///                        CONTENT_TYPE, HeaderValue::from_static("text/plain"),
///                     );
///                     res
///                 }))
///             .route(web::get().to(index)));
/// }
/// ```
Register a resource middleware function.
This function accepts instance of `ServiceRequest` type and
mutable reference to the next middleware in chain.

This is similar to `App's` middlewares, but middleware get invoked on resource level.
Resource level middlewares are not allowed to change response
type .


Register a resource middleware function . This function accepts instance of ` ServiceRequest ` type and mutable reference to the next middleware in chain . This is similar to ` App ' s ` middlewares but middleware get invoked on resource level . Resource level middlewares are not allowed to change response type .
pub fn wrap_fn<F, R>(
        self,
        mw: F,
    ) -> NormalizedResource<
        impl NewService<
            Config = (),
            Request = ServiceRequest,
            Response = ServiceResponse,
            Error = Error,
            InitError = (),
        >,
    >
    where
        F: FnMut(ServiceRequest, &mut T::Service) -> R + Clone,
        R: IntoFuture<Item = ServiceResponse, Error = Error>,
    {
        self.wrap(mw)
    }
pub fn wrap_fn < F , R > ( self , mw : F , ) -> NormalizedResource < impl NewService < Config = ( ) , Request = ServiceRequest , Response = ServiceResponse , Error = Error , InitError = ( ) , > , > where F : FnMut ( ServiceRequest , & mut T :: Service ) -> R + Clone , R : IntoFuture < Item = ServiceResponse , Error = Error > , { self . wrap ( mw ) }
Register a resource middleware function.
Register a resource middleware function .
self
mw
F
use futures::future;
use actix_web::{web, App};
use actix_web::http::{header::CONTENT_TYPE, HeaderValue}.

fn index() -> &'static str {
"Welcome!"
}

fn main() {
let app = App::new().service(
web::normalized_resource("/index.html")
.wrap_fn(|req, srv|
srv.call(req).map(|mut res| {
res.headers_mut().insert(
CONTENT_TYPE, HeaderValue::from_static("text/plain"),
);
res
}))
.route(web::get().to(index)));
}
```
use actix_web :: { web App } ; use actix_web :: http :: { header :: CONTENT_TYPE HeaderValue } . fn index () - > & ' static str { " Welcome! " } fn main () { let app = App :: new () . service ( web :: normalized_resource ( " / index . html " ) . wrap_fn ( |req srv| srv . call ( req ) . map ( |mut res| { res . headers_mut () . insert ( CONTENT_TYPE HeaderValue :: from_static ( " text / plain " ) ) ; res } )) . route ( web :: get () . to ( index ))) ; } ` ` `