Skip to content

Instantly share code, notes, and snippets.

@hemikak
Last active March 29, 2019 10:47
Show Gist options
  • Save hemikak/75f7c01c3f7e2231049a47ff3d9dd475 to your computer and use it in GitHub Desktop.
Save hemikak/75f7c01c3f7e2231049a47ff3d9dd475 to your computer and use it in GitHub Desktop.
Ballerina service to get quotes from Game of Thrones(with annotations and trimmed)
import ballerina/http;
import ballerina/log;
import ballerinax/kubernetes;
import ballerinax/openshift;
@openshift:Route {
host: "www.got-quote.com"
}
@kubernetes:Service {}
listener http:Listener gotServiceEP = new(9090); // ballerina service endpoint
http:Client gotQuoteAPI = new("https://got-quotes.herokuapp.com/quotes"); // game of thrones API endpoint
@kubernetes:Deployment {
namespace: "got-quote-proj",
registry: "172.30.1.1:5000",
buildImage: false,
buildExtension: "openshift"
}
@http:ServiceConfig {
basePath: "/got" // basepath for my service
}
service gotService on gotServiceEP {
...
}
# Validates character.
#
# + character - Game of Thrones character.
# + return - Untainted character or error if invalid character.
function validateCharacter(string character) returns string|error {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment