Xboard/app/Http/Routes/V1/ServerRoute.php

26 lines
818 B
PHP
Raw Normal View History

2023-11-17 01:44:01 -05:00
<?php
namespace App\Http\Routes\V1;
2023-12-04 07:40:49 -05:00
use App\Exceptions\ApiException;
2023-11-17 01:44:01 -05:00
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) {
2023-12-04 07:40:49 -05:00
$controllerClass = "\\App\\Http\\Controllers\\V1\\Server\\" . ucfirst($class) . "Controller";
if(!(class_exists($controllerClass) && method_exists($controllerClass, $action))){
throw new ApiException('Not Found',404);
2023-12-04 07:40:49 -05:00
};
$ctrl = \App::make($controllerClass);
2023-11-17 01:44:01 -05:00
return \App::call([$ctrl, $action]);
});
});
}
}