Skip to content

Add static factory methods to ApiGatewayRequestIdentity and AwsProxyRequestContext #1496

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dgomesbr
Copy link

Issue #, if available:
issue #1495

Description of changes:
This PR resolves issue #1495 by implementing static factory methods for both ApiGatewayRequestIdentity and AwsProxyRequestContext classes.

Implemented Changes

  1. Added getApiGatewayRequestIdentity() to ApiGatewayRequestIdentity class:

    • Creates an instance with realistic default values based on typical API Gateway requests
    • Sets appropriate values for all fields (including userAgent and sourceIp)
    • Null values for fields that typically don't have defaults
  2. Added getApiGatewayRequestIdentity(String sourceIp) to ApiGatewayRequestIdentity class:

    • Allows specifying a custom source IP while keeping other defaults
  3. Added getAwsProxyRequestContext() to AwsProxyRequestContext class:

    • Creates an instance with realistic default values from API Gateway
    • Sets appropriate values for all fields
    • Uses the default ApiGatewayRequestIdentity
  4. Added getAwsProxyRequestContext(String httpMethod) to AwsProxyRequestContext class:

    • Allows specifying a custom HTTP method while keeping other defaults

Benefits

  • Simplifies testing and priming implementations by providing easy-to-use factory methods
  • Reduces boilerplate code needed to set up these objects
  • Follows a similar approach to the one in reference implementation (AmazonAPIGatewayPrimingResource)

Questions for Maintainers

  1. Is the naming convention getAwsProxyRequestContext() and getApiGatewayRequestIdentity() preferred, or would you prefer a different naming pattern like builder() or of()?
  2. Are there specific default values for certain fields that you'd like to change?
  3. Would additional overloaded methods with different parameters be useful?

I've tested these changes locally and they work as expected.

By submitting this pull request

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I confirm that I've made a best effort attempt to update all relevant documentation.

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

Successfully merging this pull request may close these issues.

1 participant