Skip to content

Instantly share code, notes, and snippets.

@jabaraster
Last active June 24, 2018 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jabaraster/80ff7ca31a279a14215e083486c24320 to your computer and use it in GitHub Desktop.
Save jabaraster/80ff7ca31a279a14215e083486c24320 to your computer and use it in GitHub Desktop.
JavaでServerless Frameworkを使うときのリクエストとレスポンスには注意が必要 ref: https://qiita.com/jabaraster/items/f5805223d87a9f888774
{
"httpMethod" : "POST",
"requestContext" : {
"httpMethod" : "POST",
"accountId" : "*******",
"apiId" : "*******",
"resourceId" : "******",
"identity" : {
"userAgent" : "Apache-HttpClient\/4.5.x (Java\/1.8.0_112)",
"userArn" : "arn:aws:iam::******:user\/****",
"caller" : "***************",
"cognitoAuthenticationProvider" : null,
"cognitoIdentityId" : null,
"accessKey" : "******************",
"accountId" : "*****************",
"sourceIp" : "test-invoke-source-ip",
"apiKey" : "test-invoke-api-key",
"cognitoAuthenticationType" : null,
"cognitoIdentityPoolId" : null,
"user" : "*******************"
},
"requestId" : "test-invoke-request",
"stage" : "test-invoke-stage",
"resourcePath" : "\/hello"
},
"resource" : "\/hello",
"pathParameters" : null,
"isBase64Encoded" : false,
"headers" : null,
"path" : "\/hello",
"stageVariables" : null,
"queryStringParameters" : null,
"body" : "{\n \"key1\": \"hoge\",\n \"key2\": 120\n}"
}
package hello;
import java.io.IOException;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
public class Handler implements RequestHandler<Request, Response> {
@Override
public Response handleRequest(Request input, Context context) {
return new Response("Go Serverless v1.0! Your function executed successfully!", input);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment