Class ResponseWriter<ContainerResponseType,ResponseType>

java.lang.Object
com.amazonaws.serverless.proxy.ResponseWriter<ContainerResponseType,ResponseType>
Type Parameters:
ContainerResponseType - The response object expected from the underlying container
ResponseType - The type for the Lambda function return value
Direct Known Subclasses:
AwsProxyHttpServletResponseWriter

public abstract class ResponseWriter<ContainerResponseType,ResponseType> extends Object
Implementations of this object are used by the container to transform the container's response object into a valid return type for the AWS Lambda function. The ContainerResponseType type could be a response model object or a ResponseReader implementation. For example, the Jersey library passes the response reader object to the default implementation of this class.
  • Constructor Details

    • ResponseWriter

      public ResponseWriter()
  • Method Details

    • writeResponse

      public abstract ResponseType writeResponse(ContainerResponseType containerResponse, com.amazonaws.services.lambda.runtime.Context lambdaContext) throws InvalidResponseObjectException
      Writes status code, headers, and body from the container response to a Lambda return value.
      Parameters:
      containerResponse - The container response or response reader object
      lambdaContext - The context for the Lambda function execution
      Returns:
      A valid return value for the Lambda function
      Throws:
      InvalidResponseObjectException - When the implementation cannot read the container response object
    • isValidUtf8

      protected boolean isValidUtf8(byte[] input)
      Checks whether the given byte array contains a UTF-8 encoded string
      Parameters:
      input - The byte[] to check against
      Returns:
      true if the contend is valid UTF-8, false otherwise