forked from membrane/api-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxies.xml
More file actions
57 lines (51 loc) · 1.83 KB
/
proxies.xml
File metadata and controls
57 lines (51 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<spring:beans xmlns="http://membrane-soa.org/proxies/1/"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd">
<router>
<!--
JSON template with a variable
-->
<api port="2000" method="GET">
<request>
<template contentType="application/json" pretty="yes">
{ "answer": ${params.answer} }
</template>
</request>
<return statusCode="200"/><!-- To forward to backend use target below instead of return -->
<!-- <target host="YourBackendHost" port="YourBackendPort"/>-->
</api>
<!--
JSON input is converted to XML and directed to logger, the response is then converted back to JSON and returned.
-->
<api port="2000" method="POST">
<request>
<!-- Value of "city" field of the incoming JSON is inserted into XML -->
<template contentType="application/xml">
<![CDATA[
<city>${json.city}</city>
]]>
</template>
</request>
<!--
setProperty extracts the "city" from the XML.
The extracted value is placed inside a JSON template.
Note: Consider that the response flow is going from bottom to top.
-->
<response>
<template contentType="application/json">
{"city": ${property.city.toString()} }
</template>
<setProperty name="city" value="${/city}" language="xpath"/><!-- Is executed on the way back -->
</response>
<target host="localhost" port="3000" /><!-- Calls logger API below -->
</api>
<api name="logger" port="3000">
<request>
<log/><!-- Logs the incoming messages -->
</request>
<return/>
</api>
</router>
</spring:beans>