Skip to content

Instantly share code, notes, and snippets.

@riyafa
Last active March 21, 2018 09:40
Show Gist options
  • Select an option

  • Save riyafa/bf9ab9a36edecd2fc060c3039f0cdd39 to your computer and use it in GitHub Desktop.

Select an option

Save riyafa/bf9ab9a36edecd2fc060c3039f0cdd39 to your computer and use it in GitHub Desktop.
working http client
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