【发布时间】:2023-11-06 14:49:01
【问题描述】:
我正在尝试 RESTful 到 RESTful 的映射。我的终点是http://samples.openweathermap.org/data/2.5/weather?q=London,uk
我将它映射到
http://localhost:8080/get_weather/uk/London
这是我的资源源视图,
<api name="API_1" context="get_weather" hostname="http://localhost" port="8080">
<resource method="GET" uri-template="/{p1}/{p2}/">
<inSequence>
<log level="custom">
<property name="param1" expression="get-property('uri.var.p1')" />
<property name="param2" expression="get-property('uri.var.p2')" />
</log>
<send>
<endpoint key="http://samples.openweathermap.org/data/2.5/weather?q{param2},{param1}" />
</send>
</inSequence>
</resource>
</api>
最后我会用curl来发出请求
curl -i -H "Accept: application/json" -X GET http://localhost:8080/get_weather/uk/London
如何使用endpoint中记录的参数?
【问题讨论】: