Skip to content

Instantly share code, notes, and snippets.

View ldclakmal's full-sized avatar
🎯
Focusing

Chanaka Lakmal ldclakmal

🎯
Focusing
View GitHub Profile
@ldclakmal
ldclakmal / http2-server-push--server-1.1.0.bal
Last active January 27, 2023 03:23
Ballerina service for HTTP/2 server push
import ballerina/http;
listener http:Listener helloWorldEP = new(9095, config = { httpVersion: "2.0" });
service hello on helloWorldEP {
resource function sayHello(http:Caller caller, http:Request req) {
// Send a Push Promises for 2 resources with 2 methods.
http:PushPromise promise1 = new(path = "/resource1", method = "GET");
@ldclakmal
ldclakmal / http2-server-push--client-1.1.0.bal
Last active January 17, 2020 09:56
Ballerina client for HTTP/2 server push
import ballerina/http;
import ballerina/log;
http:Client clientEP = new("http://localhost:9095", config = { httpVersion: "2.0" });
public function main() {
// Submit a `GET` request.
http:Request serviceReq = new;
http:HttpFuture httpFuture = checkpanic clientEP->submit("GET", "/hello/sayHello", serviceReq);
@ldclakmal
ldclakmal / ballerina-github-project.bal
Created November 5, 2018 08:17
Print GitHub projects and list of projects withing a repository
import ballerina/config;
import ballerina/http;
import ballerina/io;
import ballerina/log;
import wso2/github4;
endpoint github4:Client githubClient {
clientConfig: {
auth: {
scheme: http:OAUTH2,
@ldclakmal
ldclakmal / .gitignore
Last active January 13, 2025 14:40
A powerful git-ignore file all programming languages and IDEs
# Build tool files
.gradle/
.mvn/
/out
/build
node_modules/
# Compiled class file
*.class
@ldclakmal
ldclakmal / http_server.go
Last active March 5, 2019 11:58
Go HTTP Server
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
@ldclakmal
ldclakmal / http2_server.go
Last active March 5, 2019 11:58
Go HTTP/2 Server
package main
import (
"fmt"
"golang.org/x/net/http2"
"io/ioutil"
"log"
"net/http"
)
@ldclakmal
ldclakmal / http_client.go
Last active April 20, 2019 04:46
Go HTTP Client
package main
import (
"bytes"
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"log"
"net/http"
@ldclakmal
ldclakmal / http2_client.go
Last active April 20, 2019 04:46
Go HTTP/2 Client
package main
import (
"bytes"
"crypto/tls"
"crypto/x509"
"fmt"
"golang.org/x/net/http2"
"io/ioutil"
"log"
@ldclakmal
ldclakmal / twitter-client-1.2.0.bal
Last active May 1, 2020 13:45
Twitter Client in Ballerina
import ballerina/encoding;
import ballerina/http;
# The Twitter client object.
public type Client client object {
http:Client twitterClient;
Credential twitterCredential;
public function __init(Configuration twitterConfig) {
@ldclakmal
ldclakmal / twitter-client-test-1.2.0.bal
Last active May 1, 2020 14:22
Twitter Client Test in Ballerina
import ballerina/io;
import ballerina/test;
Configuration twitterConfig = {
consumerKey: "Twitter App Consumer Key",
consumerSecret: "Twitter App Consumer Secret",
accessToken: "Twitter App Access Token",
accessTokenSecret: "Twitter App Access Token Secret",
};
Client twitterClient = new(twitterConfig);