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