public static function manage(HttpListener $request, array $routes, string $baseurl = "")
    {
        $controller = null;
        $baseSimilar = 0;
        $path = $request->server->get('REQUEST_URI');
        
        if ($path == "") {
            $path = "/";
        }
        
        foreach ($routes as $route) {
            if ($route['visibility'] === "disabled") {
                continue;
            }
            $mat = Routing::matches($baseurl.$route['path'], $path, $route);
            if (($mat['similar'] > $baseSimilar)) {
                $baseSimilar = $mat['similar'];
                if (isset($mat["locale"])) {
                    $route["locale"] = $mat["locale"];
                }
                $controller = $route;

                if (isset($controller['params']) && count($controller['params']) > 0) {
                    $pval = AppTools::assembly($controller['params'], $mat['result']);

                    if ($pval != false) {
                        $controller['pval'] = $pval;
                        unset($controller['params']);
                    }
                }
            }
        }
        return ($controller);
    }