Skip to content

Instantly share code, notes, and snippets.

@oroce
Created November 10, 2012 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oroce/4051301 to your computer and use it in GitHub Desktop.
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
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