laughinghan/choreographer — pull request #8 by lodewijkadlp (2012-01-14 22:55:47+00:00)
Title: Get arguments

I recently did a pull request that would've broken everything. Turns out I mixed old and new code. This is the code as I use it myself now. I tried catching GET parameters by ending with "**" but that didn't catch behind the "?", now choreographer parses the GET parameters (when present) and adds them as a last parameter.

Eg: router.get('/register/*/*', function(req, res, username, password){ console.log(username + ':' + password); });
or router.get('/register', function(req, res, args){ res.end(args.username + ':' + args.password); });
or router.get('/register/*', function(req, res, lobby, args) { res.end('Entered lobby ' + lobby + 'arguments: ' + JSON.stringify(args));} );

As you can see it's fairly elegant. Someone who doesn't know it's there doesn't notice it. It allows slightly more "standard compliant" behavior of putting arguments behind the "?".