api.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. use Illuminate\Http\Request;
  3. /*
  4. |--------------------------------------------------------------------------
  5. | API Routes
  6. |--------------------------------------------------------------------------
  7. |
  8. | Here is where you can register API routes for your application. These
  9. | routes are loaded by the RouteServiceProvider within a group which
  10. | is assigned the "api" middleware group. Enjoy building your API!
  11. |
  12. */
  13. Route::prefix('v1')
  14. ->group(function () {
  15. // Admin
  16. Route::prefix('admin')
  17. ->middleware('admin')
  18. ->group(function () {
  19. Route::any('/{class}/{action}', function($class, $action) {
  20. $ctrl = \App::make("\\App\\Http\\Controllers\\Admin\\" . ucfirst($class) . "Controller");
  21. return \App::call([$ctrl, $action]);
  22. });
  23. });
  24. // User
  25. Route::prefix('user')
  26. ->middleware('user')
  27. ->group(function () {
  28. Route::any('/{action}', function($action) {
  29. $ctrl = \App::make("\\App\\Http\\Controllers\\User\\UserController");
  30. return \App::call([$ctrl, $action]);
  31. });
  32. Route::any('/{class}/{action}', function($class, $action) {
  33. $ctrl = \App::make("\\App\\Http\\Controllers\\User\\" . ucfirst($class) . "Controller");
  34. return \App::call([$ctrl, $action]);
  35. });
  36. Route::get('server/log/fetch', 'User\\ServerController@logFetch');
  37. });
  38. // Passport
  39. Route::prefix('passport')
  40. ->group(function () {
  41. Route::any('/{class}/{action}', function($class, $action) {
  42. $ctrl = \App::make("\\App\\Http\\Controllers\\Passport\\" . ucfirst($class) . "Controller");
  43. return \App::call([$ctrl, $action]);
  44. });
  45. });
  46. // No Auth
  47. Route::prefix('guest')
  48. ->group(function () {
  49. Route::any('/{class}/{action}', function($class, $action) {
  50. $ctrl = \App::make("\\App\\Http\\Controllers\\Guest\\" . ucfirst($class) . "Controller");
  51. return \App::call([$ctrl, $action]);
  52. });
  53. });
  54. // Client
  55. Route::prefix('client')
  56. ->middleware('client')
  57. ->group(function () {
  58. Route::any('/{action}', function($action) {
  59. $ctrl = \App::make("\\App\\Http\\Controllers\\Client\\ClientController");
  60. return \App::call([$ctrl, $action]);
  61. });
  62. Route::any('/{class}/{action}', function($class, $action) {
  63. $ctrl = \App::make("\\App\\Http\\Controllers\\Client\\" . ucfirst($class) . "Controller");
  64. return \App::call([$ctrl, $action]);
  65. });
  66. });
  67. // Server
  68. Route::prefix('server')
  69. ->group(function () {
  70. Route::any('/{class}/{action}', function($class, $action) {
  71. $ctrl = \App::make("\\App\\Http\\Controllers\\Server\\" . ucfirst($class) . "Controller");
  72. return \App::call([$ctrl, $action]);
  73. });
  74. });
  75. });