Skip to content

Instantly share code, notes, and snippets.

@dunithd
Last active May 13, 2020 16:19
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 dunithd/87c69d6139658b0ce5ac76a80da16fa5 to your computer and use it in GitHub Desktop.
Save dunithd/87c69d6139658b0ce5ac76a80da16fa5 to your computer and use it in GitHub Desktop.
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