public function apply(Request $request, Match $match, array $middlewares = [])
    {
        // get the pipe of route selected by router
        $pipe = $match->getOption('pipe');

        // check if pipe is valid
        if (!is_array($pipe)) {
            // early return
            return $this->resolve($request, $match);
        }
        // filter the middlewares using the pipe of match
        $piping = array_filter($middlewares, function ($middleWare) use ($pipe) {
            // check if alias of middleware is in pipe
            return in_array($middleWare->alias(), $pipe);
        });

        // check if exists valid middlewares
        if (!count($piping)) {
            // early return
            return $this->resolve($request, $match);
        }

        // inject the handler into the HttpResponse middleware
        $that = $this;
        $piping[] = new HttpResponse(function () use ($that, $request, $match) {
            // resolve the request using the match
            return $that->resolve($request, $match);
        });

        // create a delegate with the middlewares
        $delegate = new Delegate($piping);

        // start the pipe
        return $delegate->process($request);
    }
public function apply(Request $request, Match $match, array $middlewares = [])
    {
        // get the pipe of route selected by router
        $pipe = $match->getOption('pipe');

        // check if pipe is valid
        if (!is_array($pipe)) {
            // early return
            return $this->resolve($request, $match);
        }
        // filter the middlewares using the pipe of match
        $piping = array_filter($middlewares, function ($middleWare) use ($pipe) {
            // check if alias of middleware is in pipe
            return in_array($middleWare->alias(), $pipe);
        });

        // check if exists valid middlewares
        if (!count($piping)) {
            // early return
            return $this->resolve($request, $match);
        }

        // inject the handler into the HttpResponse middleware
        $that = $this;
        $piping[] = new HttpResponse(function () use ($that, $request, $match) {
            // resolve the request using the match
            return $that->resolve($request, $match);
        });

        // create a delegate with the middlewares
        $delegate = new Delegate($piping);

        // start the pipe
        return $delegate->process($request);
    }
public function apply ( Request $ request , Match $ match , array $ middlewares = [ ] ) { // get the pipe of route selected by router $ pipe = $ match -> getOption ( 'pipe' ) ; // check if pipe is valid if ( ! is_array ( $ pipe ) ) { // early return return $ this -> resolve ( $ request , $ match ) ; } // filter the middlewares using the pipe of match $ piping = array_filter ( $ middlewares , function ( $ middleWare ) use ( $ pipe ) { // check if alias of middleware is in pipe return in_array ( $ middleWare -> alias ( ) , $ pipe ) ; } ) ; // check if exists valid middlewares if ( ! count ( $ piping ) ) { // early return return $ this -> resolve ( $ request , $ match ) ; } // inject the handler into the HttpResponse middleware $ that = $ this ; $ piping [ ] = new HttpResponse ( function ( ) use ( $ that , $ request , $ match ) { // resolve the request using the match return $ that -> resolve ( $ request , $ match ) ; } ) ; // create a delegate with the middlewares $ delegate = new Delegate ( $ piping ) ; // start the pipe return $ delegate -> process ( $ request ) ; }
Apply the middleware's to Match

@param Request $request
@param Match $match
@param array $middlewares ([])
@return ResponseInterface
@throws SimplesRunTimeError
Apply the middleware s to Match