2017-06-23 106 views
1

我制作了一个Lambda/API网关功能,它具有代理参数作为URL中的最终参数。Lambda + API网关:可选的代理服务器参数

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 - >website: site.com, proxy: blog/hello-world - > URL成功地工作在浏览器中。
  • /content/site.com - >website: site.com - > URL在浏览器中失败(缺少身份验证令牌,又名API资源未找到)。

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

回答

3

只听听两个事件。

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

这是我一直在做什么,但我最近碰到了我的CF模板资源的限制,所以我希望能消除一些端点 – Kristian

+0

好了, '/'表示你需要将它们分开。如果你调用'/ content/site.com /'会发生什么? –