繁体   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