Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Aws lambda λ+;API网关:可选代理参数_Aws Lambda_Aws Api Gateway_Serverless Framework - Fatal编程技术网

Aws lambda λ+;API网关:可选代理参数

Aws lambda λ+;API网关:可选代理参数,aws-lambda,aws-api-gateway,serverless-framework,Aws Lambda,Aws Api Gateway,Serverless Framework,我创建了一个Lambda/API网关函数,该函数将代理参数作为URL中的最终参数 page: handler: handlers/website/getRenderedPage.get events: - http: method: get path: /content/{website}/{proxy+} cors: true request: paramet

我创建了一个Lambda/API网关函数,该函数将代理参数作为URL中的最终参数

  page:
    handler: handlers/website/getRenderedPage.get
    events:
      - http:
          method: get
          path: /content/{website}/{proxy+}
          cors: true
          request:
            parameters:
              paths:
                proxy: true
                website: true  
根据定义,这就是我所经历的行为:

  • /content/site.com/blog/hello world
    -->
    网站:site.com,代理:blog/hello world
    -->URL在浏览器中成功运行
  • /content/site.com
    -->
    网站:site.com
    -->URL在浏览器中失败(缺少身份验证令牌,未找到aka API资源)

是否可以使
{proxy+}
参数可选?

只需让它侦听两个事件即可

  • /content/{website}
  • /content/{website}/{proxy+}

这就是我一直在做的,但我最近在CF模板中遇到了资源限制,所以我希望消除一些端点。
/
意味着需要将它们分开。如果改为调用
/content/site.com/
会发生什么?