-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexController.php
More file actions
28 lines (25 loc) · 910 Bytes
/
IndexController.php
File metadata and controls
28 lines (25 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
declare(strict_types=1);
namespace App\Controller;
use PhpRest2\Controller\Attribute\{Controller, Action};
use PhpRest2\Controller\ControllerBuilder;
use PhpRest2\ApiResult;
#[Controller('')]
class IndexController
{
/***************************************************************************************
* 获取所有路由信息
**************************************************************************************/
#[Action('GET:/apis')]
public function getApis()
{
$app = \PhpRest2\Application::getInstance();
$controllerBuilder = $app->get(ControllerBuilder::class);
$controllers = [];
foreach($app->getControllers() as $classPath) {
$controller = $controllerBuilder->build($classPath);
$controllers[] = $controller;
}
return ApiResult::success($controllers);
}
}