Router.

@param string      $path
@param string|null $method
@param string|null $host

@return RouteInterface|null
352716
public function match(string $path, ?string $method, ?string $host): ?RouteInterface{
        if("/" !== mb_substr($path, 0, 1)){
            $path   = "/" . $path;
        }

        $stack      = new \SplStack();

        foreach(array_reverse(explode("/", $path)) as $segment){
            $stack->push($segment);
        }

        return $this->recursionMatch($this->rootNode, $stack, $method, $host);
    }
656765
private function getPathPrefix(RouteInterface $route, $host = null)
    {
        $context = $route->getContext();

        if (null === $host) {
            $host = $route->getHost() ? $route->getHost() : $this->request->getHost();
        }

        if (null !== $route->getHost() && !(bool)preg_match($context->getHostRegex(), $host)) {
            throw new \InvalidArgumentException('Host requirement does not match given host.');
        }

        return sprintf('%s://%s', $this->getRouteProtocol($route, $this->getRequest()), $host);
    }
214971
public function match($path, $method=null)
    {
        foreach($this->routes as $pattern => $handler) {

            if ($params = Matcher::verify($pattern, $path, $method)) {
                if ($handler instanceof Handler) {
                    $handler = $handler->params($params);
                    $data    = $handler->data;
                    $data['path'] = $path;
                    $data['method'] = $method;
                    return new Route($data);
                }
                return [$handler, $params];
            }
        }
        return null;
    }
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));
    }
460125
protected static function _route($path, $result)
  {
    return Route::with(RequestConstraint::i()->path($path))->setHandler($result);
  }
8932
public function map(array $methods, string $pattern, $callable) : RouteInterface
    {
        $route = $this->getRouter()->map($methods, $pattern, $callable);

        return $route;
    }
1080854
public function get($path, callable $handler): RouterInterface
    {
        $ruler = $this->createRuler('GET', $path);
        return $this->addRuler($ruler, $handler);
    }
665550
public function run($url = null, $method = null)
    {
        $request = new Request($method, $url);
        try {
//            foreach ($this->modules as $module) {
//
//            }

            Profiler::start('router');
            if ($match = $this->router->match($url, $method)) {
                if ($match['name'] === 'handleFilesystem') {
                    Profiler::stop('router');
                    return $this->handleFilesystem($match['params'], $request);
                } else {
                    $target = $match['target'];
                    $module = $target[0];
                    if ($module instanceof Module) {
                        if ($this->isEnabled($module->title)) {
                            $this->runningModule = $module;
                            $controller = $target[1];
                            $request->setParams($match['params']);
                            Profiler::stop('router');
                            return $module->run($controller, $request);
                        } else {
                            Profiler::stop('router');
                            return $this->mainModule->run(new ErrorController("This module is disabled by your 
                            policy"),
                                $request);
                        }
                    }
                }
            }
            Profiler::stop('router');


            return $this->mainModule->run(new ErrorController("Controller for '$url' not found. " .
                $this->getRoutes()),
                $request);
        } catch (\Exception $ex) {
            Events::dispatch('onException', $ex);
            return $this->mainModule->run(new ExceptionController($ex), $request);
        } catch (\Throwable $ex) {
            Events::dispatch('onError', $ex);
            return $this->mainModule->run(new ExceptionController($ex), $request);
        }
    }
1225095
public function request($method, $path = null, array $arguments = [], $content = null)
    {
        return $this->requestService->request($method, $this, $path, $arguments, $content);
    }
1272560
public function match($path, $method, $action = null)
    {
        $rule = new Rule\HttpMethodRule();
        $rule->setPath($path);
        $rule->setMethod($method);
        $rule->setAction($action);
        $this->rules[] = $rule;
        return $rule;
    }
1108076
public function create($host = null) : HttpServerDoc
    {
        $serverDoc = new HttpServerDoc();
        if (null !== $this->jsonRpcEndpoint) {
            $serverDoc->setEndpoint($this->jsonRpcEndpoint);
        }
        if (null !== $host) {
            $serverDoc->setHost($host);
        }

        $this->appendMethodsDoc($serverDoc);

        $event = new ServerDocCreatedEvent($serverDoc);
        $this->dispatcher->dispatch($event::EVENT_NAME, $event);

        return $serverDoc;
    }
1017744
public RouteResult<T> route(HttpMethod method, String path) {
		return route(method, path, Collections.emptyMap());
	}
343589
public function get($method = null)
    {
        return is_null($method) ? $this->getRoutes() : Arr::get($this->routes, $method, []);
    }
956742
public function findRoute(string $method, string $url, string $host = null): bool
    {
        $this->method = $method;
        $this->url = $this->removeQueryFromUrl($url);
        $this->host = $host;

        return $this->find();
    }
1259863
public function dispatch($method = null, $path = null)
    {
        $match = $this->getMatch($method, $path);

        foreach ($match->before as $filter) {
            if (empty($filter)) {
                continue;
            }
            $response = $this->executeCallback($this->getFilterCallback($filter), $match->args, true);
            if (!is_null($response)) {
                return $response;
            }
        }

        $routeResponse = $this->executeCallback($match->callback, $match->args);

        foreach ($match->after as $filter) {
            if (empty($filter)) {
                continue;
            }
            array_unshift($match->args, $routeResponse);
            $response = $this->executeCallback($this->getFilterCallback($filter), $match->args, true);
            if (!is_null($response)) {
                return $response;
            }
        }

        return $routeResponse;
    }
1161823
private function pushHttpVerbe($method, $path, $cb)
    {
        $input = $this->request;

        if ($input->has('_method')) {
            if ($input->get('_method') === $method) {
                $method = $input->get('_method');
            }
        }

        return $this->routeLoader($method, $path, $cb);
    }
807801
protected function addPathToViewPaths(array &$paths, $host)
    {
        $path = $this->createViewPath($host);

        if ($path && !in_array($path, $paths)) {
            $paths[] = $path;
        }

        return $path;
    }