Xboard/app/Http/Routes/V1/ServerRoute.php
2023-12-04 20:40:49 +08:00

26 lines
818 B
PHP

<?php
namespace App\Http\Routes\V1;
use App\Exceptions\ApiException;
use Illuminate\Contracts\Routing\Registrar;
class ServerRoute
{
public function map(Registrar $router)
{
$router->group([
'prefix' => 'server',
'middleware' => 'server'
], function ($router) {
$router->any('/{class}/{action}', function($class, $action) {
$controllerClass = "\\App\\Http\\Controllers\\V1\\Server\\" . ucfirst($class) . "Controller";
if(!(class_exists($controllerClass) && method_exists($controllerClass, $action))){
throw new ApiException(404,'Not Found');
};
$ctrl = \App::make($controllerClass);
return \App::call([$ctrl, $action]);
});
});
}
}