public function wrap($callable, $params = [])
    {
        $kernel = new ClosureHttpKernel();

        if (is_callable($callable)) {
            $middleware = $callable($kernel);
        } else {
            // Add kernel as 'app' parameter
            $params = ['app' => $kernel] + $params;
            $makeMethod = method_exists($this->container, 'makeWith') ?  'makeWith' : 'make';
            $middleware = $this->container->$makeMethod($callable, $params);
        }

        if ($middleware instanceof TerminableInterface) {
            return new TerminableClosureMiddleware($kernel, $middleware);
        }

        return new ClosureMiddleware($kernel, $middleware);
    }