src/Application/CallbackHandler.php
protected function middleware(FinalCallback $callback, ServerRequestInterface $request)
    {
        $response = $this->container->get(self::RESPONSE);

        if (interface_exists(Application::MIDDLEWARE) === true) {
            $middleware = new Dispatcher($this->middlewares, $response);

            $delegate = new Delegate($callback);

            $result = $middleware->process($request, $delegate);
        }

        return isset($result) ? $result : $callback($request);
    }
protected function middleware(FinalCallback $callback, ServerRequestInterface $request)
    {
        $response = $this->container->get(self::RESPONSE);

        if (interface_exists(Application::MIDDLEWARE) === true) {
            $middleware = new Dispatcher($this->middlewares, $response);

            $delegate = new Delegate($callback);

            $result = $middleware->process($request, $delegate);
        }

        return isset($result) ? $result : $callback($request);
    }
Dispatches the middlewares of the specified request, if there are any.

@param  \Rougin\Slytherin\Application\FinalCallback $callback
@param  \Psr\Http\Message\ServerRequestInterface    $request
@return \Psr\Http\Message\ResponseInterface|null