API网关使用输入直通无服务器1.x配置http集成

问题描述 投票:0回答:2

有没有办法将所有参数,标题和正文映射到另一个http端点?它需要一个特殊的模板吗?

这是我到目前为止所得到的:

functions:
  myfunction:
    handler: lambda.myfunction # dummy hanlder
    events:    
      - http:
          path: resource/{resourceId}/other
          method: get
          integration: HTTP
          request:
            uri: http://url/resource/{resourceId}/other
            parameters:
              'method.request.path.resourceId': true
              'method.request.header.my-header': true
          response:
            statusCodes:
              200:
                pattern: ''

每当我在控制台中直接创建时,默认情况下启用直通选项,它会正确映射resourceId

我试着查看文档,但似乎几乎没有关于http集成的文档,除非我遗漏了一些东西。

amazon-web-services aws-api-gateway serverless-framework
2个回答
1
投票

有没有办法将所有参数,标题和正文映射到另一个http端点?它需要一个特殊的模板吗?

是的,使用HTTP_PROXY集成类型。在控制台中,这是“集成请求”页面中的复选框。


0
投票

我找到了一个解决方法来使这个工作,似乎更多的解决方法而不是正确的解决方案。

我必须在serverless.yml的资源中设置Integration.RequestParameters来实现这一点。

resources:
  Resources:
   ApiGatewayMethodV1ResourceResourceidVarOtherGet:
    Properties:
      RequestParameters:
        method.request.path.resourceId: true
        method.request.header.my-header: true
      Integration:
        RequestParameters:
          integration.request.path.resourceId: method.request.path.resourceId
          integration.request.header.my-header: method.request.header.my-header
© www.soinside.com 2019 - 2024. All rights reserved.