streams/Zotlabs/Lib/Api_router.php
2021-03-14 22:10:44 -07:00

32 lines
No EOL
541 B
PHP

<?php
namespace Zotlabs\Lib;
class Api_router {
static private $routes = [];
static function register($path,$fn,$auth_required) {
self::$routes[$path] = [ 'func' => $fn, 'auth' => $auth_required ];
}
static function find($path) {
if (array_key_exists($path,self::$routes)) {
return self::$routes[$path];
}
$with_params = dirname($path) . '/[id]';
if (array_key_exists($with_params,self::$routes)) {
return self::$routes[$with_params];
}
return null;
}
static function dbg() {
return self::$routes;
}
}