Last active
February 26, 2017 06:18
-
-
Save imesh/ad198b3316c3285e64ce57c90e6f0aad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.imesh.samples; | |
import ballerina.net.http; | |
import ballerina.lang.messages; | |
@http:BasePath ("/inventory") | |
service fooBarRouting { | |
@http:GET | |
resource cbrResource (message m) { | |
http:ClientConnector fooItemsEndpoint = create http:ClientConnector("http://foo.org/items"); | |
http:ClientConnector barItemsEndpoint = create http:ClientConnector("http://bar.org/items"); | |
string inventoryType = messages:getHeader(m, "INVENTORY-TYPE"); | |
message response = {}; | |
if (inventoryType == "foo") { | |
response = http:ClientConnector.post(fooItemsEndpoint, "/", m); | |
} | |
else { | |
response = http:ClientConnector.post(barItemsEndpoint, "/", m); | |
} | |
reply response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment