Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApiGwV2HttpEvent: added requestId #230

Merged
merged 4 commits into from Mar 23, 2021

Conversation

mcoup
Copy link
Contributor

@mcoup mcoup commented Mar 22, 2021

Description of changes:

  • Added requestId field as it's provided by http gateway V2 (see json below).

Tested on apigw in us-west-2:

public class TestHandler implements RequestHandler<APIGatewayV2HTTPEvent, String> {

  @Override
  public String handleRequest(APIGatewayV2HTTPEvent apiGatewayV2HTTPEvent, Context context) {
    System.out.println(apiGatewayV2HTTPEvent.getRequestContext().getRequestId());
    return null;
  }
}

Original request from apigw:

{
  "version": "2.0",
  "routeKey": "ANY /printer",
  "rawPath": "/printer",
  "rawQueryString": "",
  "headers": {
    "accept": "*/*",
    "content-length": "0",
    "host": "abcdef.execute-api.us-west-2.amazonaws.com",
    "user-agent": "curl/7.71.1",
    "x-amzn-trace-id": "Root=1-60583e5a-1f74381240de6ded5a65dbd0",
    "x-forwarded-for": "127.0.0.1",
    "x-forwarded-port": "443",
    "x-forwarded-proto": "https"
  },
  "requestContext": {
    "accountId": "123456789012",
    "apiId": "abcdef",
    "domainName": "abcdef.execute-api.us-west-2.amazonaws.com",
    "domainPrefix": "abcdef",
    "http": {
      "method": "GET",
      "path": "/printer",
      "protocol": "HTTP/1.1",
      "sourceIp": "127.0.0.1",
      "userAgent": "curl/7.71.1"
    },
    "requestId": "fakeRequestid=",  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    "routeKey": "ANY /printer",
    "stage": "$default",
    "time": "22/Mar/2021:06:51:06 +0000",
    "timeEpoch": 1616395866990
  },
  "isBase64Encoded": false
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@msailes msailes added this to Pull Request in Events Library Mar 22, 2021
@msailes msailes moved this from Pull Request to Tests Passing in Events Library Mar 22, 2021
@msailes
Copy link
Collaborator

msailes commented Mar 22, 2021

I tested this on AWS. 👍

@msailes msailes moved this from Tests Passing to Ready to release in Events Library Mar 22, 2021
Copy link
Contributor

@carlzogh carlzogh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligns with documented schema https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html - LGTM, thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants