def execute()

in scala/common/src/main/scala/com/gu/mobilepurchases/shared/lambda/LambdaApiGateway.scala [78:93]


  def execute(input: InputStream, output: OutputStream): Unit = {
    try {

      mapper.writeValue(output, objectReadAndClose(input) match {
        case Right(apiGatewayLambdaRequest) =>
          if (apiGatewayLambdaRequest.isBase64Encoded) {
            ApiGatewayLambdaResponse(LambdaResponse(HttpStatusCodes.badRequest, Some("Binary content not supported"), Map("Content-Type" -> "text/plain")))
          } else {
            val lambdaRequest: LambdaRequest = LambdaRequest(apiGatewayLambdaRequest)
            val lambdaResponse: LambdaResponse = function(lambdaRequest)
            ApiGatewayLambdaResponse(lambdaResponse)
          }
        case Left(_) => ApiGatewayLambdaResponse(internalServerError)
      })
    } finally output.close()
  }