Skip to content

Instantly share code, notes, and snippets.

Avatar

Pubudu Fernando pubudu91

View GitHub Profile
View data_mapping_ex.bal
import ballerina/http;
import ballerina/log;
// Data is formatted as: key1=val1;key2=val2
type Person record {|
string name = "";
int age = 0;
|};
listener http:Listener endpoint = new (3000);
View echo2.conf
[echo]
httpPort=9090
keystore.path="${ballerina.home}/bre/security/ballerinaKeystore.p12"
keystore.password="ballerina"
View secure-echo.conf
[echo]
httpPort=9090
httpsPort=9095
keystore.path="${ballerina.home}/bre/security/ballerinaKeystore.p12"
keystore.password="@encrypted:{92XujbVRx+rXspbI/8sbdpdrmBmMF1PBDnuVUJKdK/0=}"
View echo.conf
[echo]
httpPort=9090
httpsPort=9095
keystore.path="${ballerina.home}/bre/security/ballerinaKeystore.p12"
keystore.password="ballerina"
View echo_service.bal
import ballerina/config;
import ballerina/http;
import ballerina/log;
listener http:Listener echoListener = new http:Listener(config:getAsInt("echo.httpPort"));
listener http:Listener echoSecureListener = new http:Listener(config:getAsInt("echo.httpsPort"), config = {
secureSocket: {
keyStore: {
path: config:getAsString("echo.keystore.path"),
View simple-caching-example.bal
import ballerina/http;
endpoint http:Client cachingEP {
url: "https://jigsaw.w3.org/",
cache: {
isShared: true
}
};
@http:ServiceConfig {
View ballerina-http-caching.bal
import ballerina/http;
import ballerina/log;
endpoint http:Client cachingEP {
url: "http://localhost:8080",
cache: { isShared: true }
};
@http:ServiceConfig { basePath: "/cache" }
service<http:Service> cachingService bind { port: 9090 } {
View config-new-example.bal
import ballerina.net.http;
import ballerina.config;
endpoint<http:Service> passthroughEP {
port:9090
}
endpoint<http:Service> backendEP {
port: getBackendPort()
}
@pubudu91
pubudu91 / config-lookup.bal
Created Feb 24, 2018
Use of config API for configuring HTTP services dynamically
View config-lookup.bal
import ballerina.net.http;
import ballerina.config;
const int httpPort = initPort();
@http:configuration {port:httpPort}
service<http> echo {
@http:resourceConfig {
path:"/"
View blas-l3-mm.cpp
void blasL3(Matrix1D *A, Matrix1D *B, Matrix1D *C, int n) {
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, n, n, n, 1, A->matrix, n, B->matrix, n, 0, C->matrix, n);
}