Last active
May 13, 2020 16:19
-
-
Save dunithd/87c69d6139658b0ce5ac76a80da16fa5 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; | |
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