dimanche 8 juillet 2018

how do I put middleware on lumen route

I need to put middleware on route in lumen project. So far I've been working with Laravel but now I'm in a project that is using lumen.

Documentation here: https://lumen.laravel.com/docs/5.4/middleware

gives us

$app->get('admin/profile', ['middleware' => 'auth', function () {
    //
}]);

while my route look like this

$app->get('/', 'UsersController@all');

I've tried this:

$app->get('/', ['middleware' => 'haspermission:backend-users-list'], 'UsersController@all');

but it does not work.

What is the right way to do it if I am not using a function directly in route to return some data?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire