Created
December 3, 2016 14:05
-
-
Save BrunoBernardino/195c031143f6e4bfb346de413ecc1cd8 to your computer and use it in GitHub Desktop.
AWS Lambda Redirect code
This file contains 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
'use strict'; | |
const finish = (cb, url) => { | |
console.log('Sending to', url); | |
cb(null, {url: url}); | |
} | |
exports.handler = (event, context, callback) => { | |
const defaultURL = 'http://example.com'; | |
const testPath = event.filePath; | |
console.log('Visiting', testPath); | |
if (testPath === 'somefile.jpg') { | |
return finish(callback, 'https://finalexample.com/url/file.jpg'); | |
} | |
if (testPath === 'someotherfile.jpg') { | |
return finish(callback, 'https://finalexample.com/url/file2.jpg'); | |
} | |
// There's about 30 of these... | |
finish(callback, defaultURL); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment