简体   繁体   English

AWSa APIGatewayV2HTTPRequest 不包含 RequestContext

[英]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.

相关问题 “UnityWebRequest”不包含“结果”的定义 - 'UnityWebRequest' does not contain a definition for 'result' 找到模块 XXX,但不包含 package XXX - Module XXX found, but does not contain package XXX 深度链接不包含有效的必需参数 - Flutter 和 Firebase 动态链接 - Deep Link does not contain valid required params - Flutter with Firebase Dynamic Link go:找到模块但不包含 package - go: module found but does not contain package SendGrid 模板不包含必需的占位符 - SendGrid Template does not contain required placeholders Firestore 规则是否区分大小写或我的路径是否包含错误? - Are firestore rules case sensitive or does my path contain an error? 尝试导入错误:“firebase/app”不包含默认导出(导入为“firebase”) - Attempted import error: 'firebase/app' does not contain a default export (imported as 'firebase') Firestore 从根集合中获取所有文档(包含子集合) - Firestore get all documents (contain subcollections) from a root collection firebase 证书 object 必须包含字符串“private_key”属性 - firebase Certificate object must contain a string "private_key" property aws step 函数流中的最后一个状态是否可以包含 catch 语句? - can the last state in a aws step function flow contain a catch statement?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM