Skip to content

Instantly share code, notes, and snippets.

@hnestmann
Created July 12, 2019 12:35
Show Gist options
  • Select an option

  • Save hnestmann/f814263eb9f035ba8b7712c9a6940a2c to your computer and use it in GitHub Desktop.

Select an option

Save hnestmann/f814263eb9f035ba8b7712c9a6940a2c to your computer and use it in GitHub Desktop.
function fauxcapi() {
var HTTPClient = require('dw/net/HTTPClient');
var path = decodeURIComponent(request.httpParameterMap.path.stringValue);
var httpClient : HTTPClient = new HTTPClient();
httpClient.open('GET', 'https://' + request.httpHost + '/' + path);
httpClient.setTimeout(5000);
httpClient.send();
response.setContentType('application/json');
var expiryTime = new Date(Date.now());
expiryTime.setMinutes(expiryTime.getMinutes() + 60);
response.setExpires(expiryTime);
response.setStatus(httpClient.statusCode);
response.writer.print(httpClient.text);
}
fauxcapi.public = true;
exports.Fauxcapi = fauxcapi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment