Create and stack a new route
@param string|null $method
@param string $path
@param mixed $handlers
@return Application
541752
public function stackRoute(?string $method, string $path, $handlers)
    {
        return $this->stack(
            $this->createRoute($method, $path, $handlers)
        );
    }
526951
public static function getRoute($route, $method=null) {
// 		$routes	= static::getRoutes();
		if( $method ) {
			return isset(static::$routes[$route][$method]) ? static::$routes[$route][$method] : null;
		}
		foreach( static::getKnownMethods() as $method ) {
			if( isset(static::$routes[$route][$method]) ) {
				return static::$routes[$route][$method];
			}
		}
		return null;
	}
762679
public function createStack($handlers): Stack
    {
        if (!is_array($handlers)) {
            $handlers = [$handlers];
        }
        return new Stack(
            $handlers,
            $this->handlerResolver
        );
    }
862202
public function add($path, $handler)
    {
        $route             = new Route($path, $handler);
        $this->routes[]    = $route;
        $this->nameCache   = [];
        $this->routeParser = new RouteParser;

        return $route;
    }
136593
public function add($pattern, $paths = null, $method = null)
    {
        return $this->_addRoute($pattern, $paths, $method);
    }
619323
private function createRequest(
        string $method,
        string $path,
        $data = null,
        array $headers = [],
        bool $withAuthorization = true
    ): RequestInterface {
        $uri  = $this->baseUrl.'/'.$path;
        $body = null;

        if (in_array($method, $this->getQueryMethods())) {
            $query = is_array($data) ? http_build_query($data) : $data;

            if (is_string($query) && $query !== '') {
                $uri .= '?'.$query;
            }
        } else {
            $body = is_array($data) ? json_encode($data) : $data;
        }

        $baseHeaders = ['Content-Type' => 'application/json'];

        if ($withAuthorization) {
            $baseHeaders['Authorization'] = $this->getAuthorizationHeader();
        }

        return $this->getMessageFactory()->createRequest($method, $uri, $headers + $baseHeaders, $body);
    }
194739
public function run($method = null, $path = null)
    {
        $method = $method ?: $this->request->getMethod();
        $path   = $path ?: $this->request->currentPath();

        $this->dispatchRouter($method, $path)->send();
    }
641135
public function route(
        string $method,
        string $definition,
        RequestHandlerInterface $handler,
        ?string $name = null,
        $data = null
    ): Route {
        $route = $this->factory->create($method, $definition, $handler, $name, $data);

        $this->routes[] = $route;

        if ($name !== null) {
            $this->named[$name] = $route;
        }

        return $route;
    }
120694
public function route($method, $path, $callback)
    {
        Argument::i()
            //argument 1 should be a string
            ->test(1, 'string')
            //argument 2 should be a string
            ->test(2, 'string')
            //argument 3 should be callable
            ->test(3, 'callable');
        
        $method = strtoupper($method);
        
        if ($method === 'ALL') {
            return $this
                ->route('get', $path, $callback)
                ->route('post', $path, $callback)
                ->route('put', $path, $callback)
                ->route('delete', $path, $callback);
        }
        
        $this->routeMiddleware[$method][] = array($path, $callback);
        
        return $this;
    }
868802
function route(method, path, handler, config) {

    if( (typeof method !== 'string' && !Array.isArray(method))
        || (typeof path !== 'string')
        || (typeof handler !== 'function' && typeof handler !== 'string' && typeof handler !== 'object')
        || (config != null && typeof config !== 'object') ) {
        throw new TypeError('Bad arguments');
    }

    if (typeof method === 'string') {
        method = method.toUpperCase().replace(/\s+/g, ' ').trim().replace(/^DEL$/, 'DELETE');
        if (method.match(/ /)) {
            method = method.split(' ');
        }
    }
    if (Array.isArray(method)) {
        method = method.map(function (x) {
            return x.toUpperCase().replace(/\s+/g, ' ').trim().replace(/^DEL$/, 'DELETE');
        });
        method.forEach(function (elem) {
            if (elem.match(/[^A-Z*]/)) {
                throw new TypeError('Bad arguments');
            }
        });
    }
    return {
        method: method,
        path: path,
        handler: handler,
        config: config
    };
}
953160
public function addRoute($method, $route, $callback)
    {
        $route = $this->router->addRoute(strtoupper($method), $this->prefix . '/' . $route, $callback);

        $route->onAny(function($event, $arguments){
            $this->emit($event, $arguments);
        });

        $this->routes[] = $route;

        return $route;
    }
229197
public function dispatch(string $path, string $method = 'get')
    {
        $route = $this->_match($path, $method);

        $obj = [];

        if ($route) {
            $dispatch = $route->getStorage();
            $call = $dispatch['dispatch'] ?? [];
            $before = $dispatch['before'] ?? [];
            $after = $dispatch['after'] ?? [];
            $type = $dispatch['type'] ?? Producer::PRODUCER_SYNC;
            $params = $route->getParams();
            if (is_array($call) and class_exists($call[0])) {
                $params = $params === null ? [] : $params;
                return $this->_runProducer($call, $params, $before, $after, $type);
            }
            if (is_string($call)) {
                $obj = [$call];
            }
            return $obj;
        } else {
            return ['code' => 404];
        }

    }
492500
public function map($optionsOrMethod, $path, $handler)
    {
        $route = new Route();
        $route->map($optionsOrMethod, $path, $handler);
        $this->routes[] = $route;
        return $route;
    }
402045
public function addRoute(array $methods, string $path, string $handler)
  {
    $this->routeCollector->addRoute(
      $methods,
      $this->getPrefix().$path,
      $handler
    );

    return $this;
  }
297730
public function get(string $path, $handler, array $pathParams = [], array $opts = []): Route
    {
        return $this->add('GET', $path, $handler, $pathParams, $opts);
        // return $this->map(['GET', 'HEAD'], $path, $handler, $pathParams, $opts);
    }
811207
protected function newRoute($methods, $uri, $action)
    {
        return with(new Route($methods, $uri, $action))
            ->setRouter($this)
            ->setContainer($this->container);
    }
713743
public function method(string $method, string $uriPath, callable $handler, array $parameters = []): GroupInterface
    {
        list($middleware, $configurators, $requestFactory, $useGroupFactory, $name) =
            $this->normalizeRouteParameters($parameters);

        $uriPath = $this->normalizeUri($uriPath, $this->hasTrailSlash());

        $route = $this->createRoute($this, $method, $uriPath, $handler)
            ->setUseGroupRequestFactory($useGroupFactory)
            ->setRequestFactory($requestFactory)
            ->setConfigurators($configurators)
            ->setMiddleware($middleware)
            ->setName($name);

        return $this->addRoute($route);
    }