Return the response for the given route.

@param  \Illuminate\Http\Request  $request
@param  \Illuminate\Routing\Route  $route
@return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse
174505
protected function runRoute(Request $request, Route $route)
    {
        $request->setRouteResolver(function () use ($route) {
            return $route;
        });

        $this->events->dispatch(new Events\RouteMatched($route, $request));

        return $this->prepareResponse($request,
            $this->runRouteWithinStack($route, $request)
        );
    }
405482
public function route($route = null)
    {
        if (null === $route) {
            return $this->route;
        }
        $this->route = $route;

        return $this;
    }
902752
public function route(Request $request)
    {
        foreach ($this->routes as $route) {
            if ($route->matches($request)) {
                return $route;
            }
        }

        return null;
    }
1050628
public function matches( Route $route, Request $request )
	{
		if ( $route->httpOnly() )
			return !$request->secure();
		elseif ( $route->secure() )
			return $request->secure();

		return true;
	}
832688
private function dispatch($request, $route)
    {
        if ($route->matched()) {
            $request = $request->withPathToMatch($route->matched(), $route->trailing());
        }
        // dispatch the route!
        return $this->dispatcher->withRoute($route)->__invoke($request);
    }
1156155
public function get(string $route, $body = [], $headers = [])
    {
        return $this->request('GET', $route, $body, $headers);
    }
1042008
protected function  handleFoundRoute($route, Request $request)
    {
        $this->currentRoute = $route;
        $request->attributes->add($route[2]);

        if (isset($route[1]['middleware']) && !empty($route[1]['middleware'])) {
            $middleware = $route[1]['middleware'];
            $middleware = is_string($middleware) ? explode('|', $middleware) : (array) $middleware;
            $middleware = array_map(function ($m) { return $this->middlewareNamespace .'\\'. $m; }, $middleware);

            $response = (new Pipeline())->send($request)->through($middleware)
                ->then(function () use ($route, $request) {
                    return $this->callAction($route, $request);
                });
        }
        else {
            $response = $this->callAction($route, $request);
        }

        if (!$response instanceof Response) {
            $response = new Response($response);
        }

        return $response;
    }
1171201
public function dispatch(Route $route): Response
	{
		$onion = new Onion($this->container, null, MiddlewareInterface::class);

		$this->addMiddlewareToStack($onion, array_merge($this->globalMiddleware, $route->getMiddleware()));

		return $onion->peel(function() use ($route)
		{
			return $this->executeAction($route);
		}, [$this->request, $this->response]);
	}
150128
public function authenticate(Request $request, Route $route)
    {
        $token = $this->getToken($request);

        try {
            if (! $user = $this->auth->setToken($token)->authenticate()) {
                throw new UnauthorizedHttpException('JWTAuth', 'Unable to authenticate with invalid token.');
            }
        } catch (JWTException $exception) {
            throw new UnauthorizedHttpException('JWTAuth', $exception->getMessage(), $exception);
        }

        return $user;
    }
1216095
public function route(Request $request)
    {
        $request->setUrl($this->api->getPath($request));

        $routeParameters = $this->getRoute($request);
        if ($routeParameters) {
            $class = $routeParameters['class'];
            $function = $routeParameters['function'];
            $routeClass = new $class($this->integration, $this->api, $request);

            return $routeClass->$function();
        } else {
            return $this->api->callAPI($request);
        }
    }
1357385
private function getRoute(Request $request)
    {
        $route = $request->attributes->get('_route');

        return empty($route) ? self::UNDEFINED_ROUTE : $route;
    }
1179199
public function processRequest(Request $request, Route $route)
    {
        $givenToken = $request->headers->get(self::HEADER);

        $session = $request->getSession();
        $expectedToken = $session->get(self::CSRF);
        if ($request->isMethod('GET') && (!$route->hasOption(self::CSRF)) || $route->hasDefault('_guest')) {
            if (empty($expectedToken)) {
                $this->renewCsrfToken();
            }
            return;
        }

        if (empty($givenToken) || $givenToken !== $expectedToken) {
            throw new MethodNotAllowedException(['POST'], 'invalid CSRF token');
        }

        $this->generateNewTokenWhenNeeded($session);
    }
264
public function dispatch(Route $route, Request $request = null)
    {
        $context = $this->context;

        if (empty($this->context) && !empty($request)) {
            // If we have no context, but do have a request, prepare a context to store path variables in.
            // Otherwise routing path variables would be lost for no good reason.
            $context = new Context();
            $context->registerInstance($request);
        }

        if (!empty($context)) {
            // If we have a context, ensure that the route is made available in it.
            $context->registerInstance($route);

            if (!empty($request)) {
                // If we have a request, map the path variables and pass them to the context as primitive types by name.
                // This will allow us to inject info from a route e.g. "/view/$userId" to a $userId variable.
                $pathVariables = VariableUrl::extractUrlVariables($request->getRequestUri(), $route->getPattern());

                foreach ($pathVariables as $name => $value) {
                    $context->registerVariable($name, $value);
                }
            }
        }

        return $route->action($context);
    }
7705
protected function callAttachedBefores($route, $request)
	{
		foreach ($route->beforeFilters() as $filter => $parameters)
		{
			$response = $this->callRouteFilter($filter, $parameters, $route, $request);

			if ( ! is_null($response)) return $response;
		}
	}
606735
protected function runRouteWithinStack(Route $route, Request $request)
    {
        $middleware = $this->gatherRouteMiddlewares($route);
        
        return (new Pipeline($this->container))
                        ->send($request)
                        ->through($middleware)
                        ->then(function ($request) use ($route) {
                            return $this->prepareResponse(
                                $request,
                                $route->run($request)
                            );
                        });
    }
1063262
public function dispatch( Route $route, Request $request, $controller, $method )
	{
		$instance = $this->makeController( $controller );

		return $this->callWithinStack( $instance, $route, $request, $method );
	}
709705
public function route(Request $request)
    {
        foreach ($this->getRouterList() as $router) {
            if ($router->getAPIClient()->shouldRouteRequest($request)) {
                return $router->route($request);
            }
        }

        return;
    }