whitelist certain http routes
With allow-request you can build a whitelist of routes which you want to allow. This can be handy if your building an HTTP proxy and only want to allow certain routes on the target machine to get called.
npm install allow-request
var allowRequest = require'allow-request'http = require'http'whitelist = allowRequest;// Allow GET requests to /blogwhitelistget'/blog';// Allow POST requests to /blob/commentwhitelistpost'/blog/comment';// Allow GET requests to the Users 3, 7 and 8// Notice that you are able to use any routes that you would// also be able to use in express (including RegEX) since// we are using the same route-to-regex converter.whitelistget'/user/:id'// Handing 'true' in as first parameter to 'pass' says// that the route is allow.pass3 7 8indexOfid !== -1;;var proxy = httpcreateServer// This will check if the request is permitted.whitelistcheckreqif allowedreswriteHead200 'Content-Type': 'text/plain';resend'you are allowed to pass';elsereswriteHead403 'Content-Type': 'text/plain';resend'you do not have permissions to access this resource';;;proxylisten5000;