对于如何使用 golang 并坐在HttpApi后面将自定义类型传递到我的 Lambda 函数中,我有点困惑。
考虑以下 go lambda 处理程序,它几乎是文档中示例的副本。
type MyRequestType struct {
Name string `json:"name"`
Age int `json:"age"`
}
type MyResponseType struct {
Message string `json:"message"`
}
func handler(request MyRequestType) (MyResponseType, error) {
log.Printf("received request: %v", request)
return MyResponseType{Message: fmt.Sprintf("Hello %s, you are %d years old!", request.Name, request.Age)}, nil
}
func main() {
lambda.Start(handler)
}
结果消息始终如下。
{
"message": "Hello , you are 0 years old!"
}
我有一种转储的感觉,这是不可能的Amazon API Gateway HTTP API。但我也没有找到任何文件指出这是不可能的。所以我真的想知道,如果我做错了什么?
该文档还说明了有关有效签名的一些信息:
例如func (context.Context, TIn) (TOut, error)
如果我使用的HTTP API是Payload format version 2:
是context.Context普通的golangcontext还是特别的?我在想events.APIGatewayV2HTTPRequestContext或其他人。
TInand TOut=> events.APIGatewayV2HTTPRequestand的正确类型是events.APIGatewayV2HTTPResponse什么?
青春有我
相关分类