2016-12-15 Extending others webservices

I was wondering what it would take to proxy and extend an external web services. This can be done very simple with node:

var httpProxy = require('http-proxy');
var proxy = httpProxy.createProxyServer({
  target: 'https://$URL_FOR_SERVICE_TO_EXTEND',
  changeOrigin: true

require('http').createServer(function(req, res) {
  if(/* check whether we should return a different result, 
      * i.e. the url is our new endpoint */) {
    /* res."return new result"(..) */
  } else {
    proxy.web(req, res, {});

Just npm install http-proxy before starting the program, and then you can run an augmented service.