protected function callback($middleware, ResponseInterface $response)
    {
        $middleware = is_string($middleware) ? new $middleware : $middleware;

        $callback = function ($request, $next = null) use ($middleware) {
            return $middleware($request, $next);
        };

        if ($this->approach($middleware) == self::SINGLE_PASS) {
            $callback = function ($request, $next = null) use ($middleware, $response) {
                return $middleware($request, $response, $next);
            };
        }

        return $callback;
    }