parseRoute

@param string $route
@param string $method
@param array  $options

@return  Route|boolean
356988
public function match($route, $method = 'GET', $options = [])
    {
        // Trim the query string off.
        $route = preg_replace('/([^?]*).*/u', '\1', $route);

        // Sanitize and explode the route.
        $route = parse_url($route, PHP_URL_PATH);

        $matched = $this->matcher
            ->setRoutes($this->routes)
            ->match($route, $method, $options);

        if ($matched === false) {
            throw new RouteNotFoundException(sprintf('Unable to handle request for route `%s`.', $route), 404);
        }

        return $matched;
    }
1240180
public function addRule($rule, $route, $method = '*', $option = [], $pattern = [])
    {
        // 读取路由标识
        if (is_array($rule)) {
            $name = $rule[0];
            $rule = $rule[1];
        } elseif (is_string($route)) {
            $name = $route;
        } else {
            $name = null;
        }

        $method = strtolower($method);

        if ('/' === $rule || '' === $rule) {
            // 首页自动完整匹配
            $rule .= '$';
        }

        // 创建路由规则实例
        $ruleItem = new RuleItem($this->router, $this, $name, $rule, $route, $method, $option, $pattern);

        if (!empty($option['cross_domain'])) {
            $this->router->setCrossDomainRule($ruleItem, $method);
        }

        $this->addRuleItem($ruleItem, $method);

        return $ruleItem;
    }
1104
private function _parseReturn($method, $operate = '', $options = null)
    {
        if ($operate) $operate = ' ' . $operate . ' ';
        $string = (is_null($options) && isset($this->options[$method]['0'])) ? $this->options[$method]['0'] : $options;
        if (isset($string)) {
            if (in_array($method, array('table', 'join'))) {
                $config = Config::config()->{$this->name};
                $prefix = $config['prefix'];
                unset($config);
                $string = preg_replace_callback('/__([A-Z_-]+)__/sU', function ($match) use ($prefix) {
                    return '`' . $prefix . strtolower($match[1]) . '`';
                }, $string);
            }
            return $operate . $string;
        } else
            return '';
    }
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;
		}
	}
1083601
protected function handleRequest($method, $resource, $options)
    {
        $response = null;
        try
        {
            $response = $this->handleResponse($this->getHttpClient()->request($method, $resource, $options));
        }
        catch (RequestException $e)
        {
            $this->handleException($e);
        }

        return $response;
    }
469131
private static function register($method, $url, $callback, $options = [])
    {
        $key = $method.'@'.$url;
        self::$routes[$key] = new Route($method, $url, $callback, $options);
    }
1172226
public function findStaticRoute($method, $pattern)
    {
        $method = strtolower($method);
        if (isset($this->statics[$method]) && isset($this->statics[$method][$pattern]))
            return $this->statics[$method][$pattern];
        return false;
    }
730250
protected function dispatchRouter($method, $path)
    {
        $router = $this->container['router'];
        $logger = $this->container['logger'];

        $logger->debug('Router dispatch.', ['method' => $method, 'path' => $path]);

        $router->init();
        $route_info = $router->dispatch($method, $path);

        $handler = null;
        $vars = [];

        switch ($route_info[0]) {
        case RouteDispatcher::NOT_FOUND:
            $logger->debug('Routing failed. Not Found.');
            throw new HttpNotFoundException('404 Not Found');
            break;
        case RouteDispatcher::METHOD_NOT_ALLOWED:
            $logger->debug('Routing failed. Method Not Allowd.');
            throw new HttpMethodNotAllowedException('405 Method Not Allowed');
            break;
        case RouteDispatcher::FOUND:
            $handler = $route_info[1];
            $vars = $route_info[2];
            $logger->debug('Route found.', ['handler' => $handler]);
            break;
        }

        return [$handler, $vars];
    }
1128559
public function send(string $method, string $url, array $options)
    {
        try {
            // Guzzle overwrites all query string values in the URI if queries are specified
            // in the 'query' option, so they need to be extracted first.
            $optionsPayload = $this->mergeOptions(
                ['query' => $this->parseQueryParams($url)],
                $options
            );

            $response = $this->buildClient()->request($method, $url, $optionsPayload);

            return $this->buildResponse($response);
        } catch (GuzzleException $exception) {
            // No "custom" exceptions, just rethrow whatever guzzle spits out.
            throw $exception;
        }
    }
412452
public function controller($rule, $route = '', array $option = [], array $pattern = [])
    {
        $group = new RuleGroup($this, $this->group, $rule, null, $option, $pattern);

        foreach ($this->methodPrefix as $type => $val) {
            $group->addRule('<action>', $val . '<action>', $type);
        }

        return $group->prefix($route . '/');
    }
1187411
protected function request($method, $endpoint, $options = [])
    {
        return $this->unwrapResponse($this->getHttpClient($this->getBaseOptions())->{$method}($endpoint, $options));
    }
475516
protected function getResourceAction($resource, $controller, $method, $options)
    {
        $name = $this->getResourceName($resource, $method, $options);

        return array('as' => $name, 'uses' => $controller .'@' .$method);
    }
78809
protected function getRouteObject($pattern, $method)
    {
        foreach (['REDIRECT', $method, 'ANY'] as $verb) {
            if (array_key_exists($verb, $this->routes[$pattern])) {
                $index = $this->routes[$pattern][$verb];
                return $this->callbacks[$index];
            }
        }

        return false;
    }
937180
public static function put($route, $handler, $options = [])
    {
        app()->router->put($route, $handler, $options);
    }
365995
function fromCli($route, $method = 'GET')
    {
        global $argv;

        // Extract the arguments from the CLI
        $args = array();
        for ($argnum = 0; $argnum < count($argv); $argnum++) {
            // Long argument
            if (strpos($argv[$argnum], '--') === 0) {
                $args[substr($argv[$argnum], 2)] = $argv[++$argnum];
            // Short argument.
            } elseif (strpos($argv[$argnum], '-') === 0) {
                $args[substr($argv[$argnum], 1)] = $argv[++$argnum];
            // Positional argument.
            } else {
                $args[] = $argv[$argnum];
            }
        }

        $this->route = $route;
        $this->whole_route = $route;
        $this->method = $method;
        $this->getvars = $this->postvars = $args;
    }
667809
private function performRequest($method, $url, $options) {

        try {
            switch ($method) {
                case 'GET':
                    return json_decode($this->client->get($url, $options)->getBody(), true);
                case 'POST':
                    return json_decode($this->client->post($url, $options)->getBody(), true);
                case 'PUT':
                    return json_decode($this->client->put($url, $options)->getBody(), true);
                case 'DELETE':
                    return json_decode($this->client->delete($url, $options)->getBody(), true);
                default:
                    return null;
            }
        } catch (RequestException $e) {
            throw ApiException::create($e);
        }
    }
1104746
public function miss($route, $method = '*', array $option = [])
    {
        return $this->group->addMissRule($route, $method, $option);
    }