Skip to content

Instantly share code, notes, and snippets.

@maheeka
Forked from nuwanbando/transform.bal
Last active June 23, 2017 12:37
Show Gist options
  • Save maheeka/237e4de01d13e066937285cc029e05d4 to your computer and use it in GitHub Desktop.
Save maheeka/237e4de01d13e066937285cc029e05d4 to your computer and use it in GitHub Desktop.
import ballerina.net.http;
struct Address {
string address;
string street;
string state;
string city;
string zip;
}
struct Location {
string state;
string city;
}
service transformService {
@http:Path { value: "/location"}
@http:POST {}
resource createLocation (message m) {
Address a = {number: "123",street: "glenwood",state: "NJ",city: "bloomfield",zip: "07003"};
Location l;
transform {
a.state = l.state;
a.city = l.city;
}
http:ClientConnector locationEP = create http:ClientConnector ("http://localhost:8080/service");
string reqPath = "send/location";
message response = http:ClientConnector.post(locationEP, reqPath, l);
reply response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment