Is there a concept of "before" in the Aura Router ?

37 views
Skip to first unread message

Tim Smith

unread,
Jun 14, 2016, 10:16:15 AM6/14/16
to The Aura Project for PHP

I have been looking at some sample code given by an API service recently, and they use bramus/router as their PHP routing engine.

One particular aspect of bramus/router, which (I think) doesn't exist in aura/router is the concept of "before", this extract from the bramus sample should give you a good idea of what I mean :


 
// 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();
   
}

In other words, bramus/router can be configured to do some prevalidation checks (in this case, verifying the JWT security token) before proceeding any further with the routing.

Is there any way to achive this in the present version of aura/router, or is it just something I'll have to dream of for the future ?

Thanks !

Tim

Hari K T

unread,
Jun 14, 2016, 10:46:34 AM6/14/16
to aur...@googlegroups.com
Hi,

There is no events like before / after in aura. You can argue it need to be in router, but it can also be in the application or a wrapper for Aura.Router itself.

There is another way in v3 which is like custom rules.


Some of your use cases can be done with the same.


Hari K T

You can ring me : +91 9388 75 8821

Skype  : kthari85
Twitter : harikt

--
You received this message because you are subscribed to the Google Groups "The Aura Project for PHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to auraphp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages