Skip to content

Instantly share code, notes, and snippets.

@imesh
Last active February 26, 2017 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imesh/ad198b3316c3285e64ce57c90e6f0aad to your computer and use it in GitHub Desktop.
Save imesh/ad198b3316c3285e64ce57c90e6f0aad to your computer and use it in GitHub Desktop.
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