src/Kernel/HttpKernel.php
public function dispatch(Request $request, Route $route): Response
    {
        // Build MiddlewareManager
        $middlewareManager = new MiddlewareManager(array_merge($this->middleware, $route->getMiddleware()));

        // Run the middleware stack
        return $middlewareManager->run($request, function(Request $request) use ($route): Response {

            // Callable/closure style route
            if( is_callable($route->getAction()) ){
                $action = $route->getAction();
            }

            // Class@Method style route
            elseif( is_string($route->getAction()) ) {
                $action = class_method($route->getAction());
            }
            else {
                throw new \Exception("Cannot dispatch route because target cannot be resolved.");
            }

            // Auto-resolve controller parameters
            $params = $this->resolveActionParameters($request, $action);

            return \call_user_func_array($action, $params);

        });
    }
public function dispatch(Request $request, Route $route): Response
    {
        // Build MiddlewareManager
        $middlewareManager = new MiddlewareManager(array_merge($this->middleware, $route->getMiddleware()));

        // Run the middleware stack
        return $middlewareManager->run($request, function(Request $request) use ($route): Response {

            // Callable/closure style route
            if( is_callable($route->getAction()) ){
                $action = $route->getAction();
            }

            // Class@Method style route
            elseif( is_string($route->getAction()) ) {
                $action = class_method($route->getAction());
            }
            else {
                throw new \Exception("Cannot dispatch route because target cannot be resolved.");
            }

            // Auto-resolve controller parameters
            $params = $this->resolveActionParameters($request, $action);

            return \call_user_func_array($action, $params);

        });
    }
Dispatch a request

@param Request $request
@return Response