authentication - Slim framework route middleware arguments -
i'm writing custom route authorization middleware slim. if understand "route middleware" different "middleware".
i use custom router middleware way:
$app->get('/',$acl->allow(["users","admins"]),function () use ($app) { ... });
where
$acl->allow
route middleware:
public function allow($auth=[]){ return function() use($auth){ ... }; }
in docs http://docs.slimframework.com/#route-middleware read this:
what arguments passed each route middleware callable?
each middleware callable invoked 1 argument, matched \slim\route object.
how use standard param \slim\route object , custom parameter (in example ["users","admins"]
)
this simple answer both custom , route param in route middleware callable:
public function allow($auth=[]){ return function($route) use($auth){ //this route: $route }; }
Comments
Post a Comment