问题描述
我想知道我们是否可以在 APIGEE 中为代理端点配置多个基本路径。两个基本路径的目标代理保持相同。
示例:我想确保 /hello/world 和 /hello/universe 路由到相同的目标端点并以完全相同的方式处理
<HTTPProxyConnection>
<BasePath>world</BasePath>
<BasePath>universe</BasePath>
<VirtualHost>hello</VirtualHost>
</HTTPProxyConnection>
如何实现相同的?
解决方法
<VirtualHost>
字段应指代 Apigee 虚拟主机,即完全限定域名 ('FQDN')。这是一个类似于 demo.api.company.com 的主机名。例如,第一个 / 之前的所有内容。
您的代理基本路径是 /hello,如下所示:
<BasePath>hello</BasePath>
然后您的 API 代理定义的其余部分使用流和路径匹配条件来处理您想要在 /hello/world 和 /hello/universe 上操作的不同方法
<Flow name="world_GET">
<Description>World GET</Description>
<Request>
<Step>
<Name>World01</Name>
</Step>
<Step>
<Name>World02</Name>
</Step>
</Request>
<Response/>
<Condition>((proxy.pathsuffix MatchesPath "/world") and (request.verb = "GET"))</Condition>
</Flow>
<Flow name="universe_GET">
<Description>Uni GET</Description>
<Request>
<Step>
<Name>Uni01</Name>
</Step>
<Step>
<Name>Uni02</Name>
</Step>
</Request>
<Response/>
<Condition>((proxy.pathsuffix MatchesPath "/universe") and (request.verb = "GET"))</Condition>
</Flow>