New to Grapnel but impressed with the functionality so far. I've added the ability to do something like this, which some other routing libraries support in varying formats and can be very useful:
var router = new Grapnel();
router.get('api/*', function(req, e) {
if(!isAuthorized) e.preventDefault();
});
router.get('api/secret', function(req) {
// Authorized users only!
});
I'm undecided on whether the use of preventDefault is inappropriate for this behavior, I'm happy to change it to a new method or simply return false if that would be clearer. return false would more likely be a breaking change.
New to Grapnel but impressed with the functionality so far. I've added the ability to do something like this, which some other routing libraries support in varying formats and can be very useful:
I'm undecided on whether the use of
preventDefault
is inappropriate for this behavior, I'm happy to change it to a new method or simplyreturn false
if that would be clearer.return false
would more likely be a breaking change.