Last active
March 21, 2018 09:40
-
-
Save riyafa/bf9ab9a36edecd2fc060c3039f0cdd39 to your computer and use it in GitHub Desktop.
working http client
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
| import ballerina.net.http; | |
| import ballerina.io; | |
| endpoint http:ServiceEndpoint passthruEP { | |
| port:9090 | |
| }; | |
| endpoint http:ClientEndpoint httpClient { | |
| targets: [{uri: "http://www.mocky.io"}]}; | |
| @http:ServiceConfig { | |
| basePath:"/passthru" | |
| } | |
| service<http:Service> passthrough bind passthruEP{ | |
| @http:ResourceConfig { | |
| methods:["GET"], | |
| path:"/" | |
| } | |
| passthru (endpoint conn, http:Request request) { | |
| var resp = httpClient-> get("/v2/5aa3a485310000461026e292", request); | |
| match resp { | |
| http:Response aa => {_ = conn->forward( aa);} | |
| http:HttpConnectorError err => io:println("invalid value"); | |
| } | |
| //_=conn->respondContinue(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment