我正在尝试使用设置的上下文更新 target.url,但它在 apigee 边缘代理中不起作用。我也在写目标写
我正在点击这个网址->
https://xyz-eval-test.apigee.net/v1/edgemicro_proxy_ms/rel/1/pro/2/ws/3/stage/4/helloworld/t4/helloworldIp/52.170.150.5:8082?helloworld=helloworld-java
这是我的项目结构:
EV-URI-提取
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="EV-URI-EXTRACT">
<DisplayName>EV-URI-EXTRACT</DisplayName>
<Properties/>
<URIPath>
<Pattern ignoreCase="true">/rel/{rId}/pro/{pId}/ws/{wId}/stage/{sId}/helloworld/{helloworldId}/helloworldIp/{helloworldIp}</Pattern>
</URIPath>
<QueryParam name="helloworld">
<Pattern>helloworld-{helloworldName}</Pattern>
</QueryParam>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<Source clearPayload="false">request</Source>
</ExtractVariables>
目标重写
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="target-rewrite">
<DisplayName>target-rewrite</DisplayName>
<Properties/>
<ResourceURL>jsc://js-example.js</ResourceURL>
</Javascript>
代理端点
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<Description/>
<FaultRules/>
<Flows/>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>EV-URI-EXTRACT</Name>
</Step>
</Request>
<Response/>
</PreFlow>
<HTTPProxyConnection>
<BasePath>/v1/edgemicro_proxy_ms</BasePath>
<Properties/>
<VirtualHost>default</VirtualHost>
<VirtualHost>secure</VirtualHost>
</HTTPProxyConnection>
<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>
</ProxyEndpoint>
目标端点
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
<Description/>
<FaultRules/>
<Flows/>
<PostFlow name="PostFlow">
<Request>
</Request>
<Response>
</Response>
</PostFlow>
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>target-rewrite</Name>
</Step>
</Request>
<Response>
</Response>
</PreFlow>
<HTTPTargetConnection>
<Properties/>
<URL>https://mocktarget.apigee.net/</URL>
</HTTPTargetConnection>
</TargetEndpoint>
js-exampls.js
if (context.flow=="TARGET_REQ_FLOW") {
print(context.getVariable("helloworldIp")) // PRINTS correct value
context.setVariable("target.url", context.getVariable("helloworldIp"));
print(context.getVariable("target.url"))// PRINTS In-correct value, prints default target uri
context.setVariable("target.copy.pathsuffix", false);
}
有什么帮助吗?有人可以帮我找出我在这里做的错误吗?