Skip to content

Instantly share code, notes, and snippets.

@dunithd
Last active May 13, 2020
Embed
What would you like to do?
import ballerina/log;
import ballerina/http;
import ballerina/kubernetes;
@kubernetes:Service {
name : "todos",
serviceType: "LoadBalancer"
}
listener http:Listener todosListener = new(9090);
@kubernetes:Deployment {
name : "todos",
image : "dunithd.azurecr.io/todo-service:v1"
}
@http:ServiceConfig {
basePath: "/todos"
}
service TodoService on todosListener {
@http:ResourceConfig {
methods: ["GET"],
path: "/"
}
resource function getAllTodos(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