簡體   English   中英

Apigee代理服務器,末尾加斜杠“ /”

[英]Apigee proxy with trailing slash “/”

我有一個API代理,有兩個流,一個流按照模式“ / items / {itemId}”返回項的詳細信息,另一個流按照模式: /items

<Flows>
    <Flow name="Items by Id">
    <Condition>((proxy.pathsuffix MatchesPath &quot;/{Items}&quot;) ) and (request.verb = &quot;GET&quot;)</Condition>
</Flow>

<Flow name="List of Episodes">
    <Condition>(proxy.pathsuffix MatchesPath &quot;/&quot;) and (request.verb = &quot;GET&quot;)</Condition>
</Flow>

現在,我想支持尾隨/到兩個端點,這就是我面臨的問題。 當我嘗試通過試用/調用/Items/調用API時,Apigee假定它為/Items/{itemId}Items = "" ,因此重定向並執行不同的流程。

請提出有關如何解決此問題的建議。

只需在流中添加另一行即可捕獲兩者:

<Flows>
    <Flow name="Items list">
        <Condition>((proxy.pathsuffix MatchesPath '/Items') or (proxy.pathsuffix MatchesPath '/Items/') and (request.verb = 'GET')</Condition>
    </Flow>
    <Flow name="Items by Id">
        <Condition>((proxy.pathsuffix MatchesPath '/items/{itemId}')) and (request.verb = 'GET')</Condition>
    </Flow>
<Flows>

或者,如果您確實很聰明,則可以使用“或”將它們都添加到同一條件行中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM