mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 12:35:13 +00:00
34 lines
659 B
PHP
34 lines
659 B
PHP
<?php
|
|
|
|
namespace Code\Lib;
|
|
|
|
class Api_router
|
|
{
|
|
|
|
private static $routes = [];
|
|
|
|
public static function register($path, $fn, $auth_required)
|
|
{
|
|
self::$routes[$path] = ['func' => $fn, 'auth' => $auth_required];
|
|
}
|
|
|
|
public 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;
|
|
}
|
|
|
|
public static function dbg()
|
|
{
|
|
return self::$routes;
|
|
}
|
|
}
|