Files
decpdf.site/lib/Routes.php
2026-01-18 00:53:18 +00:00

36 lines
695 B
PHP
Executable File

<?php
class Routes {
public static $api = [];
public static $web = [];
static function add_api($method, $path, $function, $auth = false) {
$r = new Route($method, $path, $function, $auth);
Routes::$api[] = $r;
}
static function add_web($method, $path, $function, $auth = false) {
$r = new Route($method, $path, $function, $auth);
Routes::$web[] = $r;
}
static function find_api($m, $path) {
foreach (Routes::$api as $route) {
if ($route->matches($m, $path)) {
return $route;
}
}
return false;
}
static function find_web($m, $path) {
foreach (Routes::$web as $route) {
if ($route->matches($m, $path)) {
return $route;
}
}
return false;
}
}