src/Middleware/Dispatcher.php
public function process(ServerRequestInterface $request, HandlerInterface $handler)
    {
        $original = $this->stack;

        $this->push(function ($request) use ($handler) {
            return $handler->{HANDLER_METHOD}($request);
        });

        foreach ($this->stack as $index => $middleware) {
            $middleware = (is_string($middleware)) ? new $middleware : $middleware;

            $this->stack[$index] = $this->transform($middleware);
        }

        $resolved = $this->resolve(0);

        array_pop($this->stack);

        $this->stack = $original;

        return $resolved($request);
    }
public function process(ServerRequestInterface $request, HandlerInterface $handler)
    {
        $original = $this->stack;

        $this->push(function ($request) use ($handler) {
            return $handler->{HANDLER_METHOD}($request);
        });

        foreach ($this->stack as $index => $middleware) {
            $middleware = (is_string($middleware)) ? new $middleware : $middleware;

            $this->stack[$index] = $this->transform($middleware);
        }

        $resolved = $this->resolve(0);

        array_pop($this->stack);

        $this->stack = $original;

        return $resolved($request);
    }
public function process ( ServerRequestInterface $ request , HandlerInterface $ handler ) { $ original = $ this -> stack ; $ this -> push ( function ( $ request ) use ( $ handler ) { return $ handler -> { HANDLER_METHOD } ( $ request ) ; } ) ; foreach ( $ this -> stack as $ index => $ middleware ) { $ middleware = ( is_string ( $ middleware ) ) ? new $ middleware : $ middleware ; $ this -> stack [ $ index ] = $ this -> transform ( $ middleware ) ; } $ resolved = $ this -> resolve ( 0 ) ; array_pop ( $ this -> stack ) ; $ this -> stack = $ original ; return $ resolved ( $ request ) ; }
Processes an incoming server request and return a response.

@param  \Psr\Http\Message\ServerRequestInterface      $request
@param  \Rougin\Slytherin\Middleware\HandlerInterface $handler
@return \Psr\Http\Message\ResponseInterface
Processes an incoming server request and return a response .