Created
July 12, 2019 12:35
-
-
Save hnestmann/f814263eb9f035ba8b7712c9a6940a2c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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