Created
December 31, 2018 16:25
-
-
Save pubudu91/d0b7a3f063f3c3341a2e80a7badaaa11 to your computer and use it in GitHub Desktop.
This file contains 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/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