Router

Config Example

//Router
'router' => [
    'single' => [
        ['GET', '/ping', [\App\services\DemoService::class, 'ping']],
        ['GET', '/redis', [\App\services\DemoService::class, 'redis', [\App\middlewares\Cors::class]]],
        ['GET', '/mysql', [\App\services\DemoService::class, 'mysql']],
        ['GET', '/http', [\App\services\DemoService::class, 'http']],
        ['GET', '/es', [\App\services\DemoService::class, 'es']],
        ['GET', '/file', [\App\services\DemoService::class, 'file']],
        ['GET', '/qiniu', [\App\services\DemoService::class, 'qiniu']],
    ],
    'group' => [
        '/admin' => [
            ['GET', '/ping', [\App\services\DemoService::class, 'ping']],
        ],
    ],
],

Format

[{Request Method}, {Path}, [{Handler}, {Handle Method}, [{Middleware1}, {Middleware2}...]]]

[{Middleware1}, {Middleware2}...] is optional.

Match Rules

Router Middleware

The router supports multiple middlewares. The priority of router middleware is lower than the one of global middleware.

Last updated

Was this helpful?