2017-06-23 61 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 /'會發生什麼? –