Class RequestReader<RequestType,ContainerRequestType>

java.lang.Object
com.amazonaws.serverless.proxy.RequestReader<RequestType,ContainerRequestType>
Type Parameters:
RequestType - The type for the AWS Lambda event
ContainerRequestType - The type for the underlying container request object
Direct Known Subclasses:
AwsHttpApiV2HttpServletRequestReader, AwsProxyHttpServletRequestReader

public abstract class RequestReader<RequestType,ContainerRequestType> extends Object
Implementations of the RequestReader object are used by container objects to transform the incoming Lambda event into a request object that can be used by the underlying container. Developers can build custom implementation of this interface to support other container types as well as custom event types. This library provides a default implementation of this object that supports requests for the AWS_PROXY integration.
  • Field Details

    • API_GATEWAY_CONTEXT_PROPERTY

      public static final String API_GATEWAY_CONTEXT_PROPERTY
      The key for the API Gateway context property in the PropertiesDelegate object
      See Also:
    • API_GATEWAY_STAGE_VARS_PROPERTY

      public static final String API_GATEWAY_STAGE_VARS_PROPERTY
      The key for the API Gateway stage variables property in the PropertiesDelegate object
      See Also:
    • ALB_CONTEXT_PROPERTY

      public static final String ALB_CONTEXT_PROPERTY
      The key for the ALB context property in the PropertiesDelegate object
      See Also:
    • API_GATEWAY_EVENT_PROPERTY

      public static final String API_GATEWAY_EVENT_PROPERTY
      The key to store the entire API Gateway event
      See Also:
    • LAMBDA_CONTEXT_PROPERTY

      public static final String LAMBDA_CONTEXT_PROPERTY
      The key for the AWS Lambda context property in the PropertiesDelegate object
      See Also:
    • JAX_SECURITY_CONTEXT_PROPERTY

      public static final String JAX_SECURITY_CONTEXT_PROPERTY
      The key for the JAX RS security context properties stored in the request attributes
      See Also:
    • HTTP_API_CONTEXT_PROPERTY

      public static final String HTTP_API_CONTEXT_PROPERTY
      The key for the HTTP API request context passed by the services
      See Also:
    • HTTP_API_STAGE_VARS_PROPERTY

      public static final String HTTP_API_STAGE_VARS_PROPERTY
      The key for the HTTP API stage variables
      See Also:
    • HTTP_API_EVENT_PROPERTY

      public static final String HTTP_API_EVENT_PROPERTY
      The key for the HTTP API proxy request event
      See Also:
  • Constructor Details

    • RequestReader

      public RequestReader()
  • Method Details

    • readRequest

      public abstract ContainerRequestType readRequest(RequestType request, jakarta.ws.rs.core.SecurityContext securityContext, com.amazonaws.services.lambda.runtime.Context lambdaContext, ContainerConfig config) throws InvalidRequestEventException
      Reads the incoming event object and produces a populated request for the underlying container
      Parameters:
      request - The incoming request object
      securityContext - A jax-rs SecurityContext object (@see com.amazonaws.serverless.proxy.SecurityContextWriter)
      lambdaContext - The AWS Lambda context for the request
      config - The container configuration object. This is passed in by the LambdaContainerHandler.
      Returns:
      A valid request object for the underlying container
      Throws:
      InvalidRequestEventException - This exception is thrown if anything goes wrong during the creation of the request object
    • getRequestClass

      protected abstract Class<? extends RequestType> getRequestClass()
    • stripBasePath

      protected String stripBasePath(String requestPath, ContainerConfig config)
      Strips the base path from the request path if the container configuration object requires it
      Parameters:
      requestPath - The incoming request path
      config - The container configuration object
      Returns:
      The final request path