import ballerina/http;
import ballerina/io;
public function main() returns error? {
// A client object is created by applying `new` to a client class.
http:Client httpClient = check new ("https://api.github.com");
// The remote method calls use the `->` syntax. This enables the sequence diagram view.
http:Response resp =
check httpClient->get("/orgs/ballerina-platform/repos");
io:println(resp.statusCode);
}
Consuming services: client objectsBallerina has a language construct called client objects.
They are a special kind of objects that contain |
import ballerina/http;
import ballerina/io;
public function main() returns error? {
http:Client httpClient = check new ("https://api.github.com");
A client object is created by applying new
to a client class.
http:Response resp =
check httpClient->get("/orgs/ballerina-platform/repos");
The remote method calls use the ->
syntax. This enables the sequence diagram view.
io:println(resp.statusCode);
}
bal run consuming_services.bal
200