Created
May 13, 2020 06:03
-
-
Save dunithd/3427d35926ed1daac5585ad5f9c4527e 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/log; | |
import ballerina/http; | |
listener http:Listener todosListener = new(9090); | |
@http:ServiceConfig { | |
basePath: "/todos" | |
} | |
service TodoService on todosListener { | |
@http:ResourceConfig { | |
methods: ["GET"], | |
path: "/" | |
} | |
resource function getAll(http:Caller caller, http:Request request) { | |
//return some mock Todo objects as a JSON array | |
json todos = [ | |
{ | |
"id" : 1, | |
"name" : "Create the Todo Service", | |
"status" : "OPEN" | |
}, | |
{ | |
"id" : 2, | |
"name" : "Create an AKS Cluster", | |
"status" : "OPEN" | |
} | |
]; | |
//respond to the caller | |
var responseResult = caller->respond(todos); | |
if (responseResult is error) { | |
log:printError("Error responding back to client.", responseResult); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment