code: function(req, res) {
          var error = {d: { __messages: [{ type: "ERROR", text: "Proxy Error", code: "PROXY"}] }};
  
          var writeError = function() {
              res.writeHead(500, {});
              res.write(JSON.stringify(error));
              res.end();
          };
  
          try {
              var body = "";
              req.on('data', function(data) {
                  body += data.toString("utf-8");
              });
  
              req.on('end', function() {
                  var destination = req.headers["X-ProxyDestination".toLowerCase()];
  
                  var options = {
                      url: destination,
                      method: req.method,
                      headers: {
                          "Content-Length": req.headers["content-length"] || 0,
                          "Content-Type": req.headers["content-type"],
                          "Authorization": req.headers["authorization"]
                      },
                      followAllRedirects: true,
                      body: body,
                      jar: false,
                      strictSSL: false
                  };
  
                  try {
                      request(options, function(err, response, data) {
                          try {
                              var statusCode = (response ? response.statusCode : 500) || 500;
                              var headers = (response ? response.headers : {}) || {};
  
                              res.writeHead(statusCode, headers);
                              res.write(data || JSON.stringify(err));
                              res.end();
                          }
                          catch (ex) {
                              writeError();
                          }
                      });
                  }
                  catch (ex) {
                      writeError();
                  }
  
              });
          }
          catch (ex) {
              writeError();
          }
      }
docs: Helpers