Skip to content

Instantly share code, notes, and snippets.

@edgars
Created November 24, 2017 20:12
Show Gist options
  • Select an option

  • Save edgars/291b8f032354d8e171e2ab7993992591 to your computer and use it in GitHub Desktop.

Select an option

Save edgars/291b8f032354d8e171e2ab7993992591 to your computer and use it in GitHub Desktop.
package mine;
import ballerina.net.http;
@http:configuration {basePath:"/dolar"}
service<http> dolar {
endpoint
<http:HttpClient> httpConnector{
create http:HttpClient("http://api.bcb.gov.br", {});}
http:HttpConnectorError err;
@http:resourceConfig {
methods:["GET"],
path:"/cotacao"
}
resource cotacao (http:Request req, http:Response res) {
http:Response clientResponse = {};
clientResponse, err = httpConnector.get("/dados/serie/bcdata.sgs.1/dados/ultimos/1?formato=json", req);
println("GET request: from Dolar Service Banco Central Brasil");
res.forward(clientResponse);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment