APIGEE中没有资源的路由
在我的API中,我有两个资源。一个资源使用默认的目标端点。至于另一个资源,我不希望它路由到默认目标。所以我没有给出路线。但它仍然被路由到默认目标。有人能帮我解决这个问题吗。查看问题的答案。查找RouteRules的详细信息列在此处。这也会有帮助 您可以使用以下代码完成您正在尝试的操作:APIGEE中没有资源的路由,api,apigee,Api,Apigee,在我的API中,我有两个资源。一个资源使用默认的目标端点。至于另一个资源,我不希望它路由到默认目标。所以我没有给出路线。但它仍然被路由到默认目标。有人能帮我解决这个问题吗。查看问题的答案。查找RouteRules的详细信息列在此处。这也会有帮助 您可以使用以下代码完成您正在尝试的操作: <RouteRule name="routeToTarget1"> <Condition>thetype == "abc"</Condition> <Ta
<RouteRule name="routeToTarget1">
<Condition>thetype == "abc"</Condition>
<TargetEndpoint>target1</TargetEndpoint>
</RouteRule>
<RouteRule name="routeToTarget2">
<Condition>thetype == "xyz"</Condition>
<TargetEndpoint>target2</TargetEndpoint>
</RouteRule>
类型==“abc”
目标1
类型==“xyz”
目标2
这些程序将按顺序进行评估
请注意,您可能希望底部RouteRule没有条件,这意味着它将始终匹配。当类型不等于“abc”或“xyz”时会发生什么情况?假设target1是默认值,您的代码如下所示:
<RouteRule name="routeToTarget2">
<Condition>thetype == "xyz"</Condition>
<TargetEndpoint>target2</TargetEndpoint>
</RouteRule>
<RouteRule name="routeToTarget1">
<TargetEndpoint>target1</TargetEndpoint>
</RouteRule>
<RouteRule name="dog">
<Condition>(proxy.pathsuffix MatchesPath "/dog") and (request.verb = "GET")</Condition>
<HTTPTargetConnection>
<URL>https://myOtherEndpoint.com</URL>
</HTTPTargetConnection>
</RouteRule>
类型==“xyz”
目标2
目标1
还有几点:
(1) 如果不需要离散目标端点的全部功能,则不必创建整个附加目标端点。您可以选择使用一个更轻量级的选项,直接路由到提供的URL,而不是通过目标端点。看起来是这样的:
<RouteRule name="routeToTarget2">
<Condition>thetype == "xyz"</Condition>
<TargetEndpoint>target2</TargetEndpoint>
</RouteRule>
<RouteRule name="routeToTarget1">
<TargetEndpoint>target1</TargetEndpoint>
</RouteRule>
<RouteRule name="dog">
<Condition>(proxy.pathsuffix MatchesPath "/dog") and (request.verb = "GET")</Condition>
<HTTPTargetConnection>
<URL>https://myOtherEndpoint.com</URL>
</HTTPTargetConnection>
</RouteRule>
(proxy.pathsuffix MatchesPath“/dog”)和(request.verb=“GET”)
https://myOtherEndpoint.com
(2) 如果您使用管理UI(edge.apigee.com),则当您使用新建资源对话框工具时,UI将同时写入条件流和路由规则
该对话框如下所示:
它将产生以下结果:
<RouteRule name="dog">
<Condition>(proxy.pathsuffix MatchesPath "/dog") and (request.verb = "GET")</Condition>
<HTTPTargetConnection>
<URL>https://myOtherEndpoint.com</URL>
</HTTPTargetConnection>
</RouteRule>
<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>
(proxy.pathsuffix MatchesPath“/dog”)和(request.verb=“GET”)
https://myOtherEndpoint.com
违约
请分享配置。了解此信息后,回答问题很容易。