-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
32 lines (25 loc) · 959 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <aws/lambda-runtime/runtime.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/utils/memory/stl/SimpleStringStream.h>
using namespace aws::lambda_runtime;
static invocation_response my_handler(invocation_request const& request)
{
using namespace Aws::Utils::Json;
JsonValue json_request(request.payload);
if (!json_request.WasParseSuccessful()) {
return invocation_response::failure("Failed to parse input JSON", "InvalidJSON");
}
auto request_view = json_request.View();
if (request_view.ValueExists("location")) {
JsonValue response;
response.WithString("given_loaction", request_view.GetString("location"));
return invocation_response::success(response.View().WriteCompact(), "application/json");
} else {
return invocation_response::failure("'location' not in payload", "InvalidJSON");
}
}
int main()
{
run_handler(my_handler);
return 0;
}