[英]AWSa APIGatewayV2HTTPRequest does not contain RequestContext
I'm trying to setup an API Gateway that forwards requests to a Lambda function.我正在尝试设置一个将请求转发到 Lambda 函数的 API 网关。 Precisely I struggle to setup CORS properly.
准确地说,我很难正确设置 CORS。 When handling the request in my Lambda function the incoming event does not have the
RequestContext
information set.在我的 Lambda 函数中处理请求时,传入事件没有设置
RequestContext
信息。 Hence I don't know when I handle an OPTIONS
request.因此,我不知道何时处理
OPTIONS
请求。
My debug code: in
is the APIGatewayV2HTTPRequest
我的调试代码:
in
APIGatewayV2HTTPRequest
log.Printf("type: %s", reflect.TypeOf(in))
log.Printf("req: %+v", in)
Output:输出:
type: events.APIGatewayV2HTTPRequest
...
RequestContext:{
RouteKey:
AccountID:xxx
Stage:default
RequestID:dB7h2jEcFiAEMkA=
Authorizer:<nil>
APIID:xxx
DomainName:xxx
DomainPrefix:xxx
Time:
TimeEpoch:0
HTTP:
{Method: Path: Protocol: SourceIP: UserAgent:}
It seems RequestContext.HTTP
is not set and I have no idea why.似乎没有设置
RequestContext.HTTP
,我不知道为什么。
I had to set the api gateway payload version to v2.我必须将 api 网关有效负载版本设置为 v2。 For some reason it was set to v1 and therefor the event was not properly populated.
由于某种原因,它被设置为 v1,因此事件没有正确填充。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.