pub fn apply<'a, Data, Handler, E>(
        self,
        handler: Handler,
        data: Data,
        include_path: Vec<&str>,
        exclude_path: E,
    ) -> Builder<MiddlewareChainLink<Data, Handler, Chain>>
    where
        Data: Sync + Send,
        Handler: 'static + MiddlewareHandler<Data> + Sync + Send,
        E: Into<Option<Vec<&'a str>>>,
    {
        let rule = Rule::new(include_path, exclude_path.into());
        Builder {
            chain: MiddlewareChainLink {
                rule,
                data,
                handler,
                rest: self.chain,
            },
        }
    }
/// Method to apply a new middleware onto the stack where the `include_path` vec are all path affected by the middleware,
/// and `exclude_path` are exclusion amongst the included paths.
///
/// ```rust
/// use saphir::middleware::Builder as MBuilder;
///# use saphir::prelude::*;
///
///# async fn log_middleware(
///#     prefix: &String,
///#     ctx: HttpContext<Body>,
///#     chain: &dyn MiddlewareChain,
///# ) -> Result<Response<Body>, SaphirError> {
///#     println!("{} | new request on path: {}", prefix, ctx.request.uri().path());
///#     let res = chain.next(ctx).await?;
///#     println!("{} | new response with status: {}", prefix, res.status());
///#     Ok(res)
///# }
///#
/// let builder = MBuilder::default().apply(log_middleware, "LOG".to_string(), vec!["/"], None);
/// ```
Method to apply a new middleware onto the stack where the `include_path` vec are all path affected by the middleware,
and `exclude_path` are exclusion amongst the included paths.

```rust
use saphir::middleware::Builder as MBuilder.
Method to apply a new middleware onto the stack where the ` include_path ` vec are all path affected by the middleware and ` exclude_path ` are exclusion amongst the included paths . ` ` ` rust use saphir :: middleware :: Builder as MBuilder .
pub fn apply<'a, Data, Handler, E>(
        self,
        handler: Handler,
        data: Data,
        include_path: Vec<&str>,
        exclude_path: E,
    ) -> Builder<MiddlewareChainLink<Data, Handler, Chain>>
    where
        Data: Sync + Send,
        Handler: 'static + MiddlewareHandler<Data> + Sync + Send,
        E: Into<Option<Vec<&'a str>>>,
    {
        let rule = Rule::new(include_path, exclude_path.into());
        Builder {
            chain: MiddlewareChainLink {
                rule,
                data,
                handler,
                rest: self.chain,
            },
        }
    }
pub fn apply < ' a , Data , Handler , E > ( self , handler : Handler , data : Data , include_path : Vec < & str > , exclude_path : E , ) -> Builder < MiddlewareChainLink < Data , Handler , Chain > > where Data : Sync + Send , Handler : ' static + MiddlewareHandler < Data > + Sync + Send , E : Into < Option < Vec < & ' a str > > > , { let rule = Rule :: new ( include_path , exclude_path . into ( ) ) ; Builder { chain : MiddlewareChainLink { rule , data , handler , rest : self . chain , } , } }
Method to apply a new middleware onto the stack where the `include_path` vec are all path affected by the middleware,
and `exclude_path` are exclusion amongst the included paths.
Method to apply a new middleware onto the stack where the ` include_path ` vec are all path affected by the middleware and ` exclude_path ` are exclusion amongst the included paths .
self
handler
Handler
data
Data
include_path
Vec<&str>
exclude_path
E
self
handler
Handler
data
Data
include_path
Vec<&str>
exclude_path
E
use saphir::prelude::*;
None
async fn log_middleware(
None
prefix: &string,
None
ctx: httpcontext<body>,
None
chain: &dyn middlewarechain,
None
) -> result<response<body>, saphirerror> {
None
println!("{} | new request on path: {}", prefix, ctx.request.uri().path());
None
let res = chain.next(ctx).await?;
None
println!("{} | new response with status: {}", prefix, res.status());
None
ok(res)
None
}
let builder = MBuilder::default().apply(log_middleware, "LOG".to_string(), vec!["/"], None);
```
let builder = MBuilder :: default () . apply ( log_middleware " LOG " . to_string () vec! [ " / " ] None ) ; ` ` `