| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?> |
| 2 |
<?php |
| 3 |
/** |
| 4 |
* This is an example of using middleware in routes. The global middleware group will be |
| 5 |
* applied to all routes. The before middleware will be executed before the policy |
| 6 |
* handler ran, and the after middleware group will be executed right after the main |
| 7 |
* callback (the main route handler) ran without any exceptions/interruptions. |
| 8 |
* The route middleware will be run if any middleware is explicitly used. |
| 9 |
*/ |
| 10 |
|
| 11 |
/** |
| 12 |
* Note: Please use class-based middleware when you need more than a few to keep |
| 13 |
* this confine clean and store the middleware in the Http/Middleware folder. |
| 14 |
*/ |
| 15 |
|
| 16 |
/** |
| 17 |
* How to use route middleware: |
| 18 |
* |
| 19 |
* $router->namespace(...)->before('auth')->after('loger')->group(...); |
| 20 |
* $router->before('auth')->after('loger')->get(...); |
| 21 |
*/ |
| 22 |
|
| 23 |
return [ |
| 24 |
'global' => [ |
| 25 |
'before' => [ |
| 26 |
|
| 27 |
], |
| 28 |
'after' => [ |
| 29 |
|
| 30 |
] |
| 31 |
], |
| 32 |
'route' => [ |
| 33 |
'before' => [ |
| 34 |
], |
| 35 |
'after' => [ |
| 36 |
|
| 37 |
], |
| 38 |
] |
| 39 |
]; |