Skip to content

Instantly share code, notes, and snippets.

@pubudu91
Created December 31, 2018 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pubudu91/d0b7a3f063f3c3341a2e80a7badaaa11 to your computer and use it in GitHub Desktop.
Save pubudu91/d0b7a3f063f3c3341a2e80a7badaaa11 to your computer and use it in GitHub Desktop.
import ballerina/config;
import ballerina/http;
import ballerina/log;
listener http:Listener echoListener = new http:Listener(config:getAsInt("echo.httpPort"));
listener http:Listener echoSecureListener = new http:Listener(config:getAsInt("echo.httpsPort"), config = {
secureSocket: {
keyStore: {
path: config:getAsString("echo.keystore.path"),
password: config:getAsString("echo.keystore.password")
}
}
});
@http:ServiceConfig {
basePath: "echo"
}
service echo on echoListener, echoSecureListener {
@http:ResourceConfig {
path: "/"
}
resource function echo(http:Caller caller, http:Request request) returns error? {
string payload = check request.getTextPayload();
var result = caller->respond(untaint payload);
if (result is error) {
log:printError("Failed to respond to caller", err = result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment