Initial import
This commit is contained in:
Executable
+35
@@ -0,0 +1,35 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user