Use of before checks in aura/router ?

48 views
Skip to first unread message

Tim Smith

unread,
Jun 14, 2016, 10:16:14 AM6/14/16
to The Aura Project for PHP
I tried to post this question earlier, but my post seems to have gone missing somewhere as it has not appeared ?

I am currently testing out an API for a third-party service, their example PHP scripts use bramus/router as PHP router.

One thing that bramus/router appears to support that aura/router does not is the concept of "before" checks, like this example given :

  // Check JWT on /secured routes
  $router
->before('GET', '/secured/.*', function() use ($app) {

    $requestHeaders
= apache_request_headers();

   
if (!isset($requestHeaders['Authorization'])) {
        header
('HTTP/1.0 401 Unauthorized');
        echo
"No token provided.";
       
exit();
   
}


i.e. in this instance, bramus/router checks JWT token authentication before proceeding any further.

Does this concept exist in aura/router (I can't seem to find it in the docs) or do I just hope it will be forthcoming in the future ?

Thanks

TIm

Hari K T

unread,
Dec 27, 2016, 2:13:33 AM12/27/16
to The Aura Project for PHP
Hi, 

Sorry for the late reply. I missed your post some how.
If you are using 3.x version you could probably add custom Rule. See http://auraphp.com/packages/3.x/Router/custom-matching.html#1-3-6

The before / after functionality is not there in Aura.

Thank you

Hari KT
Reply all
Reply to author
Forward
0 new messages