2020-03-12 14:45:49 +00:00
|
|
|
// Docs on event and context https://www.netlify.com/docs/functions/#the-handler-method
|
2021-05-22 15:20:23 +00:00
|
|
|
exports.handler = (event) => {
|
2020-06-12 03:25:17 +00:00
|
|
|
switch (event.httpMethod) {
|
2020-03-12 14:45:49 +00:00
|
|
|
case "GET":
|
|
|
|
|
try {
|
2020-06-12 03:25:17 +00:00
|
|
|
const name = event.queryStringParameters.name || "World"
|
2020-03-12 14:45:49 +00:00
|
|
|
return {
|
|
|
|
|
statusCode: 200,
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({ message: `Hello ${name}` }),
|
|
|
|
|
}
|
2021-08-11 11:27:40 +00:00
|
|
|
} catch (e) {
|
|
|
|
|
return { statusCode: 500, body: e.toString() }
|
2020-03-12 14:45:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return { statusCode: 405, body: "Method Not Allowed" }
|
|
|
|
|
}
|
|
|
|
|
}
|