Permet de définir la base de l'url dans le routeur

This commit is contained in:
2022-11-22 08:12:06 +01:00
parent 4d1ef981d2
commit 9bc53b958f

View File

@@ -22,6 +22,15 @@ class Router
$this->url = trim($url, '/');;
}
public function setBasePath(string $basePath)
{
$pos = strpos($this->url, $basePath);
if ($pos !== false) {
$this->url = substr($this->url, $pos + strlen($basePath));
}
var_dump($this->url);
}
public function get(string $path, callable $callable): self
{
return $this->addRoute('GET', $path, $callable);