How to pass a param in Slim4 route middleware?

59 views Asked by At

I'm using Slim4 and I need to pass a param in middleware route configurations.

In my example I need to define the required ROLE of user in a Authorization middleware.

I need to check that user is a manager in the first route group, and an admin in the second route group.

$app->group('',function() use ($app){        
    $app->get('/manager',ManagerAction::class.':home')->setName("manager");
})->add(UserAuthMiddleware::class);

$app->group('',function() use ($app){        
    $app->get('/admin', AdminAction::class.':home')->setName("admin");
})->add(UserAuthMiddleware::class);
1

There are 1 answers

0
wieczorek1990 On

You should check the possiblilities of the group return value and if it only allows to take class then it is probably impossible to do what you want. Maybe take it to their GitHub.