You have several options on how you could receive the httpMethod
in Java. One of the easiest would be to rename 'http-method'
to 'httpMethod'
in your Integration Request in API Gateway and then use the RequestHandler Interface for your Lambda handler which will marshal your JSON directly to a Java Object:
package example;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import com.amazonaws.services.lambda.runtime.Context;
public class Hello implements RequestHandler<PojoRequest, PojoResponse> {
public PojoResponse handleRequest(PojoRequest request, Context context) {
System.out.println(String.format("HTTP method is %s.", request.getHttpMethod()));
return new PojoResponse();
}
}
Then you can create whatever Pojo you want to be the request, for example:
package example;
public class PojoRequest {
private String firstName;
private String lastName;
private String httpMethod;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getHttpMethod() {
return httpMethod;
}
public void setHttpMethod(String httpMethod) {
this.httpMethod = httpMethod;
}
}
See: http://docs.aws.amazon.com/lambda/latest/dg/java-handler-using-predefined-interfaces.html