Add new route method one or more http methods.

@param string $methods
@param string $route
@param array|string|closure $settings
@param string|closure $callback

@return bool
495743
public function add($methods, $route, $settings, $callback = null)
    {
        if($this->cacheLoaded) {
            return true;
        }

        if (is_null($callback)) {
            $callback = $settings;
            $settings = null;
        }

        if (strstr($methods, '|')) {
            foreach (array_unique(explode('|', $methods)) as $method) {
                if ($method != '') {
                    call_user_func_array([$this, strtolower($method)], [$route, $settings, $callback]);
                }
            }
        } else {
            call_user_func_array([$this, strtolower($methods)], [$route, $settings, $callback]);
        }

        return true;
    }
469131
private static function register($method, $url, $callback, $options = [])
    {
        $key = $method.'@'.$url;
        self::$routes[$key] = new Route($method, $url, $callback, $options);
    }
1027347
public function addRoute($methods, string $pattern, string $handler)
    {
        if (is_string($methods)) {
            $methods = (array) $methods;
        }

        $methods = array_map('strtoupper', $methods);

        $this->routes[] = [
            $methods,
            $pattern,
            $handler
        ];
    }
350363
public function setRoute(array $methods, string $regexp, $callable): RouteInterface
    {
        return $this
            ->setMethods($methods)
            ->setRegexp($regexp)
            ->setCallback($callable);
    }
767624
public function add($url, $method, $action)
	{	
		$route = $this->factory->create($url, $method, $action);

		$this->routes[] = $route;

		foreach ($route->getMethod() as $method) {
			$this->routesByMethod[$method][] = $route;
		}
	}
306278
public function add(Route $route)
    {
        foreach ($route->getMethods() as $method) {
            $this->routes[$method][$route->getPath()] = $route;

            $this->allRoutes[$route->getPath()] = $route;
        }

        return $route;
    }
544366
protected function register($method, $route, $handler)
    {
        // Protect WordPress root route !
        if ($route == '/') {
            return;
        }

        // If the developer is registering multiple request methods to handle
        // the URI, we'll spin through each method and register the route
        // for each of them along with each URI and handler.

        // TODO : Only put the same method route to route array

        if (is_array($method)) {
            foreach ($method as $http) {
                $routeCollection = new Route($http, $route, new RouteHandler($handler));

                //Add this route to the $routeCollections params
                array_push($this->routeCollections, $routeCollection);
            }

            return;
        }

        // Create routeCollection from params
        $routeCollection = new Route($method, $route, new RouteHandler($handler));

        //Add this route to the $routeCollections params
        array_push($this->routeCollections, $routeCollection);

        return $this->routeCollections[sizeof($this->routeCollections) - 1];
    }
1126751
public function addRoute(array $methods, array $versions, $uri, $action)
    {
        $this->createRouteCollections($versions);

        foreach ($versions as $version) {
            foreach ($this->breakUriSegments($uri) as $uri) {
                $this->routes[$version]->addRoute($methods, $uri, $action);
            }
        }
    }
1132109
protected function setHttpMethods(Route $route, array $httpMethods)
    {
        foreach ($httpMethods as $idx => $method) {
            $httpMethods[$idx] = strtoupper($method);
        }
        $route->via($httpMethods);
    }
617208
public static function add($route, $parameters)
    {
        self::$route = $route;
        array_shift($parameters);
        self::$parameters = $parameters;
    }
1057092
public function map($methods, $match, $callback)
    {
        return $this->routeService->attach($methods, $match, $callback);
    }
1184143
protected function newRoute($methods, $uri, $action)
    {
        $route = (new Route($methods, $uri, $action))->setContainer($this->container);
        $priority = self::DEFAULT_PRIORITY - $this->routes->count();
        $route->setPriority($priority);

        return $route;
    }
17409
public function addRoute($methods, $uri, $action)
    {
        if (\is_string($action)) {
            $action = ['uses' => $action, 'controller' => $action];
        } elseif ($action instanceof Closure) {
            $action = [$action];
        }

        $action = $this->mergeLastGroupAttributes($action);

        $action = $this->addControllerMiddlewareToRouteAction($action);

        $uri = $uri === '/' ? $uri : '/'.\trim($uri, '/');

        if (! empty($action['prefix'])) {
            $uri = '/'.\ltrim(\rtrim(\trim($action['prefix'], '/').'/'.\trim($uri, '/'), '/'), '/');

            unset($action['prefix']);
        }

        $action['uri'] = $uri;

        return $this->adapter->addRoute((array) $methods, $action['version'], $uri, $action);
    }
262923
public function addRoute($method, $uri, $callBack) {
        $method = strtoupper($method);
        //预定义正则路由
        if (strpos($uri, ':') !== false) {
            $searches = array_keys($this->patterns);
            $replaces = array_values($this->patterns);
            $uri = str_replace($searches, $replaces, $uri);
            $this->regexRoutes[] = [
                'method' => $method,
                'regex' => '#^' . $uri . '$#',
                'callback' => $callBack
            ];
        } //自定义正则路由
        elseif ($uri[0] == '#'
            || (strlen($uri) > 2 && tools\Str::endsWith($uri, '/') && tools\Str::startsWith($uri, '/'))
        ) {
            $this->regexRoutes[] = [
                'method' => $method,
                'regex' => $uri,
                'callback' => $callBack
            ];
        } //直接定义的路由
        else {
            $this->routes[$method . $uri] = [
                'method' => $method,
                'uri' => $uri,
                'callback' => $callBack
            ];
        }
    }
1244354
protected function dispatchMethod($request, $route)
    {
        list($path, $var) = $this->parseUrlPath($route);

        $route = str_replace('/', '@', implode('/', $path));
        $method = strpos($route, '@') ? explode('@', $route) : $route;

        return new CallbackDispatch($request, $this, $method, $var);
    }
132147
public function controller($route, $settings, $controller = null)
    {
        if($this->cacheLoaded) {
            return true;
        }

        if (is_null($controller)) {
            $controller = $settings;
            $settings = [];
        }

        $controller = str_replace(['\\', '.'], '/', $controller);
        $controllerFile = realpath(
            rtrim($this->paths['controllers'], '/') . '/' . $controller . '.php'
        );

        if (! file_exists($controllerFile)) {
            return $this->exception($controller . ' class is not found!');
        }

        if (! class_exists($controller)) {
            require $controllerFile;
        }

        $controller = str_replace('/', '\\', $controller);
        $classMethods = get_class_methods($this->namespaces['controllers'] . $controller);
        if ($classMethods) {
            foreach ($classMethods as $methodName) {
                if(!strstr($methodName, '__')) {
                    $method = "any";
                    foreach(explode('|', RouterRequest::$validMethods) as $m) {
                        if(stripos($methodName, strtolower($m), 0) === 0) {
                            $method = strtolower($m);
                            break;
                        }
                    }

                    $methodVar = lcfirst(str_replace($method, '', $methodName));
                    $r = new ReflectionMethod($this->namespaces['controllers'] . $controller, $methodName);
                    $reqiredParam = $r->getNumberOfRequiredParameters();
                    $totalParam = $r->getNumberOfParameters();

                    $value = ($methodVar === $this->mainMethod ? $route : $route.'/'.$methodVar);
                    $this->{$method}(
                        ($value.str_repeat('/{a}', $reqiredParam).str_repeat('/{a?}', $totalParam-$reqiredParam)),
                        $settings,
                        ($controller . '@' . $methodName)
                    );
                }
            }
            unset($r);
        }

        return true;
    }
477680
public function addRoute($method, $uri, callable $handler, $hooks=[])
    {
        $this->routes[] = [$method, $uri, $handler, $hooks];
    }