Created
August 7, 2014 01:33
-
-
Save nvcexploder/299886835c3f5aa6e157 to your computer and use it in GitHub Desktop.
Change URL in a hapi onRequest ext point.
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
// wherever you're setting up your server, this was within a register method for a plugin: | |
plugin.select('api').ext('onRequest', internals.onRequest); | |
//somewhere else in that file or whatever | |
var onRequest = function (request, next) { | |
request.setUrl(exports.rewriteUrl(request.raw.req.url)); | |
next(); | |
}; | |
var rewriteUrl = function (requestUrl) { | |
/** | |
* magic to change request url | |
*/ | |
return requestUrl; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For version 16:
Line 10:
return next.continue();