Skip to content

v2.0.7

Compare
Choose a tag to compare
@gigili gigili released this 02 Oct 19:07
· 65 commits to main since this release
5f3e1a0

You can now pass arguments to middleware methods
When working with middleware methods you can also pass them arguments if you need to

$routes
    ->middleware([
        'test_middleware',
        'has_roles' => 'admin,user',
        [ Middleware::class, 'test_method' ],
        [ Middleware::class, 'has_role', 'Admin', 'Moderator', [ 'User', 'Bot' ] ],
    ])
    ->add('/test', function (Request $request) {
        $request->send([ 'msg' => 'testing' ]);
    });

Every middleware function can also accept an argument of type Gac\Routing\Request at any position as long as it has the proper type specified.