aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Fincham <michael@hotplate.co.nz>2019-03-25 22:07:18 +1300
committerGitHub <noreply@github.com>2019-03-25 22:07:18 +1300
commit74dffe8b1b9f4051dcd7410c4334f1b0a81b2c31 (patch)
tree37bf8bc1fd36535cf303196f0dad4b766e845f0f
parent55e99ea3a03c8118b58082b642332414aa04b64c (diff)
downloadlambda-host-header-redirect-74dffe8b1b9f4051dcd7410c4334f1b0a81b2c31.tar.gz
lambda-host-header-redirect-74dffe8b1b9f4051dcd7410c4334f1b0a81b2c31.tar.bz2
lambda-host-header-redirect-74dffe8b1b9f4051dcd7410c4334f1b0a81b2c31.zip
Create the-machine.js
-rw-r--r--the-machine.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/the-machine.js b/the-machine.js
new file mode 100644
index 0000000..4ed9c14
--- /dev/null
+++ b/the-machine.js
@@ -0,0 +1,23 @@
+'use strict';
+
+exports.handler = (event, context, callback) => {
+ const mappings = {
+ "example.com": "https://example.org/something",
+ "example.net": "https://example.org/something-else"
+ }
+
+ const response = {
+ status: '301',
+ statusDescription: 'Moved Permanently',
+ headers: {
+ 'location': [
+ {
+ key: 'Location',
+ value: mappings[event.Records[0].cf.request.headers.host[0].value]
+ }
+ ]
+ },
+ body: "I like shorts, they're comfortable and easy to wear."
+ };
+ callback(null, response);
+};