Call the specified route to get an example response

@param \Illuminate\Routing\Route $route
@param string $method
@return string
338889
protected function getRouteCallExampleResponse($route, $method)
	{
		$url = $this->getRouteUrlWithBindings($route);
		
		$response = $this->callRoute($method, $url, []);
		
		if (is_null($response)) {
			return null;
		}

		if (is_object($response)) {
			$response = $response->content();
		}

		return $response;
	}
1056695
public function dispatch($route, $request)
    {
        $request->setParam('Closure', $route[4]);

        if(isset($route[3]) && is_string($route[3])) {
            $view = $route[3];
            $data = $route[4];
            return ['view' => [$view, $data]];
        }
        elseif(isset($route[2]) && is_string($route[2])) {
            list($controller, $method) = explode('@', $route[2]);
            return ['controller' => [$controller, $method]];
        }
        elseif(isset($route[2]) && ($route[2] instanceof Closure || get_class($route[2]) === "Closure")) {
            $function = $route[2];
            $reflectionFunction = new ReflectionFunction($function);
            $numReqParam = $reflectionFunction->getNumberOfRequiredParameters();
            if($numReqParam > count($request->getParam('Closure'))) {
                throw new Exception('Invaliding number of required parameter passed in route\'s callable function: '.$route[1]);
            }
            ob_start();
            if($request->getParam('Closure') !== false && is_array($request->getParam('Closure')) ) {
                $return = call_user_func_array($route[2], $request->getParam('Closure'));
            }
            else {
                //$function();
                throw new Exception('Invaliding parameter passed in route\'s callable function: '.$route[1]);
            }
            $output = ob_get_clean();
            return ['output' => [$output, $return]];
        }
        else {
            throw new Exception('Invaliding route is registered for: '.$route[1]);
        }
    }
1009982
protected function call( $instance, $route, $method )
	{
		$parameters = $this->resolveClassMethodDependencies( $route->parametersWithoutNulls(), $instance, $method );

		return $instance->callAction( $method, $parameters );
	}
474518
protected function match($method, $uri)
    {
        $result = null;

        foreach ((array) $this->router->routes() as $route)
        {
            $matched = preg_match($route->regex(), $uri, $matches);

            if ($matched && $route->method() === $method)
            {
                return array($matches, $route);
            }
        }

        return $result;
    }
166862
public function dispatch(Route $route, $controller, $method)
    {

        // This is not very nice but with the current structure we have to throw
        // the previously created controller away.
        // For further implementations more cleanup has to be done
        $instance = $this->makeController(is_object($controller) ? get_class($controller) : $controller);

        $parameters = $this->resolveClassMethodDependencies(
            $route->parametersWithoutNulls(), $instance, $method
        );

        if ($this->creator && method_exists($this->creator, 'modifyMethodParameters')) {
            $this->creator->modifyMethodParameters($instance, $method, $parameters);
        }

        if (method_exists($instance, 'callAction')) {
            return $instance->callAction($method, $parameters);
        }

        return $instance->{$method}(...array_values($parameters));

    }
1315105
public function getByMethod($method = null)
    {
        if (is_null($method)) {
            return $this->getRoutes();
        }

        // Filter routes by the given method
        return ArrayHelper::get($this->routes, $method, []);
    }
666308
protected function buildCallbackFromControllerRoute($route)
    {
        list($controller, $methodName) = $this->determineClassAndMethod($route);
        $app      = & $this;
        $callable = function () use ($app, $controller, $methodName) {
            // Get action arguments
            $args = func_get_args();
            // Try to fetch the instance from Slim's container, otherwise lazy-instantiate it
            $instance = $app->container->has($controller) ? $app->container->get($controller) : new $controller($app);

            return call_user_func_array(array($instance, $methodName), $args);
        };

        return $callable;
    }
586894
protected function matchRoute(array $routes, $method, IUrl $url) {
        foreach ($routes as $route) {
            if ($this->compareRouteToMethod($route, $method) &&
                $this->getUrlMatcher()->match($route->getPath(), $url->getPath()) &&
                $this->getRestrictionsMatcher()->match($url)
            ) {
                $parameters = $this->getUrlMatcher()
                    ->parse($route->getPath(), $url->getPath());

                $route->setParameters($parameters->toArray());

                return $route;
            }
        }

        return null;
    }
469663
private function callControllerMethod(Controller $controller, $method)
    {
        return app()->call([$controller, $method], ParameterBag::getParameters());
    }
1209319
public function getMatch($method = null, $path = null)
    {
        $method = $method ?: $this->getRequestMethod();
        $path   = $path ?: $this->getRequestPath();

        $method = strtoupper($method);

        $methodNotAllowed = null;

        foreach ($this->routes as $pattern => $methods) {
            preg_match($this->regexifyPattern($pattern), $path, $matches);

            if ($matches) {
                $r = $this->getRouteObject($pattern, $method);

                if (!$r) {
                    // We found a match but with the wrong method
                    $methodNotAllowed = true;
                    continue;
                }

                $r->method = strtoupper($method);
                $r->args   = $this->getMatchArgs($matches);

                return $r;
            }
        }

        if ($methodNotAllowed) {
            if ($this->methodNotAllowed) {
                return (object)[
                    'before'   => [],
                    'after'    => [],
                    'args'     => [],
                    'callback' => &$this->methodNotAllowed,
                ];
            }

            throw new MethodNotAllowedException;
        }

        if ($this->notFound) {
            return (object)[
                'before'   => [],
                'after'    => [],
                'args'     => [],
                'callback' => &$this->notFound,
            ];
        }

        throw new NotFoundException;
    }
1141974
private function callControllerMethod(Controller $controller, $method)
    {
        return App::call([$controller, $method], ParameterBag::getParameters());
    }
684355
public function callAction($route, Request $request)
    {
        if ($request->isMethod('OPTIONS')) {
            return new Response(null, 200);
        }

        // 闭包
        foreach ($route[1] as $value) {
            if ($value instanceof Closure) {
                return call_user_func_array($value, $route[2]);
                break;
            }
        }

        list($class, $method) = explode('@', $route[1]['uses']);
        $controller = $this->namespace.'\\'.$class;
        $instance =  new $controller();

        if (!method_exists($instance, $method)) {
            return call_user_func_array([$instance, "missingMethod"], [$method, $route[2]]);
        }

        return call_user_func_array([$instance, $method], $route[2]);
    }
861046
private function getMethods(Route $route)
    {
        $methods = $route->getMethods();
        sort($methods);

        return implode('|', $methods) ?: 'ANY';
    }
6966
public function dispatch($method, $uri)
    {
        $routeInfo = $this->dispatcher->dispatch($method, $uri);

        if($routeInfo[0] === Dispatcher::NOT_FOUND) {

            $this->filterRequest('*', $method);

            $routeInfo = $this->dispatcher->dispatch($method, '*');

            if(!$routeInfo[0]) {
                throw new Exception("Route [ {$uri} ] not found.");
            }
        }

        if($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) {
            $method = $_SERVER['REQUEST_METHOD'];
            throw new Exception("[ $method ] method not allowed.");
        }

        if($routeInfo[0] === Dispatcher::FOUND) {
            $handler = $routeInfo[1];
            $params = $routeInfo[2];

            if(!empty($filterResponse = $this->filterRequest($uri, $method))) {
                return $filterResponse;
            }

            return $this->methodDispatcher($handler, $params);
        }
    }
485250
protected function storeRoute(array $methods, array $route)
    {
        $this->callbacks[] = (object)$route;
        $index             = count($this->callbacks) - 1;

        if (!isset($this->routes[$route['pattern']])) {
            $this->routes[$route['pattern']] = [];
        }

        if ($route['name']) {
            $this->names[$route['name']] = $index;
        }

        foreach ($methods as $method) {
            $this->routes[$route['pattern']][strtoupper($method)] = $index;
        }
    }
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)
                            );
                        });
    }
453648
protected function _parse_search($uri, $route = null, $method = null)
	{
		if ($route === null)
		{
			$route = $this;
		}

		if (is_array($route->translation))
		{
			foreach ($route->translation as $r)
			{
				$verb = $r[0];

				$protocol = isset($r[2]) ? ($r[2] ? 'https' : 'http') : false;

				if (($protocol === false or $protocol == \Input::protocol()) and $method == strtoupper($verb))
				{
					$r[1]->search = $route->search;
					$result = $route->_parse_search($uri, $r[1], $method);

					if ($result)
					{
						return $result;
					}
				}
			}

			return false;
		}

		if ($this->case_sensitive)
		{
			$result = preg_match('#^'.$route->search.'$#uD', $uri, $params);
		}
		else
		{
			$result = preg_match('#^'.$route->search.'$#uiD', $uri, $params);
		}

		if ($result === 1)
		{
			return $route->matched($uri, $params);
		}
		else
		{
			return false;
		}
	}