<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit="http://www.mulesoft.org/schema/mule/apikit" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/apikit http://www.mulesoft.org/schema/mule/apikit/current/mule-apikit.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<http:listener-config name="american-flights-api-httpListenerConfig" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<apikit:config name="american-flights-api-config" raml="american-flights-api.raml" consoleEnabled="false" doc:name="Router"/>
<flow name="american-flights-api-main">
<http:listener config-ref="american-flights-api-httpListenerConfig" path="/api/*" doc:name="HTTP"/>
<apikit:router config-ref="american-flights-api-config" doc:name="APIkit Router"/>
<exception-strategy ref="american-flights-api-apiKitGlobalExceptionMapping" doc:name="Reference Exception Strategy"/>
</flow>
<flow name="american-flights-api-console">
<http:listener config-ref="american-flights-api-httpListenerConfig" path="/console/*" doc:name="HTTP"/>
<apikit:console config-ref="american-flights-api-config" doc:name="APIkit Console"/>
</flow>
<flow name="put:/flights/{ID}:application/json:american-flights-api-config">
<set-payload value="{
"message" : "Flight updated (but not really)"
}" doc:name="Set Payload"/>
</flow>
<flow name="delete:/flights/{ID}:american-flights-api-config">
<set-payload value="{
"message" : "Flight deleted (but not really)"
}" doc:name="Set Payload"/>
</flow>
<flow name="get:/flights:american-flights-api-config">
<set-payload value="[
{
"ID" : 1,
"code" : "ER38sd",
"price" : 400,
"departureDate" : "2017/07/26",
"origin" : "CLE",
"destination" : "SFO",
"emptySeats" : 0,
"plane" : {
"type" : "Boeing 737",
"totalSeats" : 150
}
},
{
"ID" : 2,
"code" : "ER45if",
"price" : 540.99,
"departureDate" : "2017/07/27",
"origin" : "SFO",
"destination" : "ORD",
"emptySeats" : 54,
"plane" : {
"type" : "Boeing 777",
"totalSeats" : 300
}
}
]" doc:name="Set Payload"/>
</flow>
<flow name="get:/flights/{ID}:american-flights-api-config">
<set-payload value="{
"ID" : 1,
"code" : "ER38sd",
"price" : 400,
"departureDate" : "2017/07/26",
"origin" : "CLE",
"destination" : "SFO",
"emptySeats" : 0,
"plane" : {
"type" : "Boeing 737",
"totalSeats" : 150
}
}" doc:name="Set Payload"/>
</flow>
<flow name="post:/flights:american-flights-api-config">
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{
"responsemesssage" : "Flight record added (honest joe, it's in there)"
}" doc:name="Set Payload"/>
</flow>
<apikit:mapping-exception-strategy name="american-flights-api-apiKitGlobalExceptionMapping">
<apikit:mapping statusCode="404">
<apikit:exception value="org.mule.module.apikit.exception.NotFoundException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ "message": "Resource not found" }" doc:name="Set Payload"/>
</apikit:mapping>
<apikit:mapping statusCode="405">
<apikit:exception value="org.mule.module.apikit.exception.MethodNotAllowedException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ "message": "Method not allowed" }" doc:name="Set Payload"/>
</apikit:mapping>
<apikit:mapping statusCode="415">
<apikit:exception value="org.mule.module.apikit.exception.UnsupportedMediaTypeException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ "message": "Unsupported media type" }" doc:name="Set Payload"/>
</apikit:mapping>
<apikit:mapping statusCode="406">
<apikit:exception value="org.mule.module.apikit.exception.NotAcceptableException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ "message": "Not acceptable" }" doc:name="Set Payload"/>
</apikit:mapping>
<apikit:mapping statusCode="400">
<apikit:exception value="org.mule.module.apikit.exception.BadRequestException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ "message": "Bad request" }" doc:name="Set Payload"/>
</apikit:mapping>
</apikit:mapping-exception-strategy>
</mule>
Comments