Created
November 10, 2012 14:47
-
-
Save oroce/4051301 to your computer and use it in GitHub Desktop.
node-restify before hook to serve different version of routes based on query string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var qs = require( "querystring" ); | |
server.pre(function( req, res, next ){ | |
var query = qs.parse( req.query() ); | |
req._version = query.version||undefined; //if `version` isn't defined, let node-restify to decide which is the best version | |
next(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment