小编jro*_*151的帖子

HTTP请求主体未通过AWS API Gateway进入AWS Lambda函数

我有一个用Scala编写的非常基本的lambda函数,已部署到AWS Lambda。当我通过AWS Lambda控制台对其进行测试时,该功能可以正常工作。

这是功能,其中添加了一些其他日志记录以用于调试目的。

package com.spacecorpshandbook.ostium.lambda.handler

import java.util

import com.google.gson.Gson
import temp.{ApiGatewayProxyResponse, Appointment, CancelResponse}

/**
  * Amazon Lambda handler adapter for the Cancellation application
  */
class CancellationHandler {

  def cancelAppointment(appointment: Appointment): ApiGatewayProxyResponse = {

    System.out.println("++++ appointmentId is: " + appointment.getAppointmentId)

    val apiGatewayProxyResponse = new ApiGatewayProxyResponse
    val cancelResponse = new CancelResponse

    cancelResponse.setMessage("Cancelled appointment with id " + appointment.getAppointmentId)

    val gson: Gson = new Gson

    apiGatewayProxyResponse.setBody(gson.toJson(cancelResponse))

    apiGatewayProxyResponse.setStatusCode("200")

    val headerValues = new util.HashMap[String, String]

    headerValues put("Content-Type", "application/json")

    apiGatewayProxyResponse.setHeaders(headerValues)

    System.out.println("+++++ message before returning: " …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-lambda aws-api-gateway

2
推荐指数
1
解决办法
3124
查看次数