Created
November 24, 2017 20:12
-
-
Save edgars/291b8f032354d8e171e2ab7993992591 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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