Create a new route
@param null|string $method
@param string $path
@param mixed $handlers
@return Route
8736
public function createRoute(?string $method, string $path, $handlers): Route
    {
        if ($handlers instanceof \Peak\Blueprint\Http\Stack) {
            return new Route($method, $path, $handlers);
        }
        if (!is_array($handlers)) {
            $handlers = [$handlers];
        }
        return new Route($method, $path, new Stack($handlers, $this->getHandlerResolver()));
    }
937613
private function matchSequentiallyForMethods(array $methods, string $path)
    {
        if ($result = $this->matchKeyValue($path, $methods)) {
            return $result;
        }

        foreach ($methods as $currentMethod) {
            foreach ($this->routes[$currentMethod] ?? [] as $handler => $handlerData) {
                foreach ($handlerData as list($patternRoute, $extraParams)) {
                    /** @var PatternRoute $patternRoute */
                    /** @var array $extraParams */
                    if ($patternRoute->match($path, $queryParams)) {
                        return new InternalRoute($handler, \array_replace($extraParams, $queryParams));
                    }
                }
            }
        }

        return null;
    }
1217946
public function method($method, $path = null)
	{
		if($path !== null)
			$this->setPath($path);

		return $this->setMethod($method);
	}
872634
protected function createRequest($method, $path, $value = null)
    {
        list($path, $value) = $this->evaluatePathValueArguments(array($path, $value));
        return $this->client->createRequest($method, $this->buildUrl($path), $this->buildOptions($value));
    }
764524
public function findFromPath($path, $method = null)
    {
        foreach ($this->getRoutes() as $route) {
            if ($matchedRoute = $route->matches($path, $method)) {
                return $matchedRoute;
            }
        }
        return null;
    }
730312
public function middleware($path, $handler = null)
    {
        if ($handler === null) {
            $handler = $path;
            $path = '/';
        }

        $path = $this->normalizePath($path);
        $this->middleware_handlers[$path][] = $handler;

        return $this;
    }
1243245
protected function createRoute($methods, $uri, $action)
    {
        // Transform an action controller to a Closure action
        if ($this->isActionController($action)) {
            $action = $this->convertToControllerAction($action);
        }

        // Create new route
        $route = $this->newRoute(
            $methods, $uri, $action
        );

        return $route;
    }
566449
public function map($pattern, $handler = null, $methods = '*')
    {
        $this->routes[$pattern] = [
            'handler' => $handler,
            'methods' => $methods,
        ];
    }
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;
    }
492500
public function map($optionsOrMethod, $path, $handler)
    {
        $route = new Route();
        $route->map($optionsOrMethod, $path, $handler);
        $this->routes[] = $route;
        return $route;
    }
165805
public function create(
       string $action,
       string $prefix,
       string $controller,
       array $param,
       string $path): RouteInterface
   {
       try {
           return $this->proto->clone()
               ->setAction($action)
               ->setPrefix($prefix)
               ->setController($controller)
               ->setParam($param)
               ->setPath($path);
       } catch (InvalidArgumentException $e) {
           throw new InvalidArgumentException(
               "Can't create route: " . $e->getMessage());
       }
   }
691537
public static function delete($path, $handlerMethod = null)
    {
        return self::factory($path, HttpMethods::DELETE, $handlerMethod);
    }
133348
private function routeLoader($method, $path, $cb)
    {
        // We build the original path based on the application loader
        $path = $this->config['app.root'].$this->prefix.$path;

        // We define the current route and current method
        $this->current = ['path' => $path, 'method' => $method];

        // We add the new route
        $route = new Route($path, $cb);

        $route->middleware($this->middlewares);

        $this->routes[$method][] = $route;

        $route->middleware('trim');

        if (in_array($method, ['POST', 'DELETE', 'PUT'])) {
            $route->middleware('csrf');
        }

        return $route;
    }
564331
private function collectRoute(String $method, String $path, Callable $callback) : Route {

		if(in_array([$path, $method], $this->getRoutes()))
			throw new RouterException('Route already defined.');

		$route = new Route($method, $path, $callback);
		array_push($this->routes, $route);
		return $route;

	}
438242
protected function createRoute(array $methods, string $name, string $path, $target, array $matchers = []) : Route
    {
        $builder = RouteBuilder::route($this->defaultRouteClass);

        $builder->from($path)->to($target);

        foreach ($methods as $method) {
            $builder->accepting($method);
        }

        $builder->named($name);

        foreach ($matchers as $param => $paramMatchers) {
            foreach ($paramMatchers as $matcher) {
                $builder->ifMatches($param, $matcher);
            }
        }

        return $builder->build();
    }
365342
public function request(string $path, int $methods, $handler)
	{
		$path = $this->currentContext->getPrefixedPath(
			trim($path, "\n\r\t/ ")
		);

		return $this->route(new Route($path, $methods), $handler);
	}
314386
protected function createRoute($methods, $uri, $action)
    {
        $route = parent::createRoute($methods, $uri, $action);
        if (! empty($this->groupStack)) {
            $route = $this->mergePriority($route);
        }

        return $route;
    }