ukayani / restify-router

A router interface for restify that lets you aggregate route definitions and apply to a restify server
MIT License
52 stars 15 forks source link

Chaining handlers #2

Closed danielfigueiredo closed 8 years ago

danielfigueiredo commented 8 years ago

Is there any way to chain handlers using this library? I tried to but after I return calling next() the next function doesn't get called.

router.get(
    '/foo/:id',
    function(req, res, next) {
        console.log('Authenticate!');
        return next();
    },
    function(req, res, next) {
        res.send(200);
        return next();
    }
);
danielfigueiredo commented 8 years ago

Sorry this was my mistake!

calvinlfer commented 8 years ago

Glad to hear its working :smile:, may I ask what was the issue? We usually invoke next() instead of return next()

calvinlfer commented 8 years ago

Ah I see now, you called res.send(200) which would terminate the chain so next() won't go through