36 lines
695 B
PHP
Executable File
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;
|
|
}
|
|
|
|
}
|