Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Building a Microgateway in Ballerina_KubeCon 2108

API gateways play a critical role in modern enterprise architecture. As microservices strengthen their hold on modern-day application architectures, cloud native API gateways are high in demand. Ballerina, being a programming language designed to address and simplify the complexities of heavily distributed systems primarily built on microservice architectures, provides a rich set of language features and a smart compiler that makes it a good choice of technology to build a cloud native API gateway.

14.
Listeners and Filters service passthrough on new http:Listener
(9090) {
import wso2/gateway;
AuthnFilter authnFilter;
OAuthzFilter authzFilter;
RateLimitFilter rateLimitFilter;
AnalyticsFilter analyticsFilter;
ExtensionFilter extensionFilter;
listener gateway:APIGatewayListener
apiListener = new (9095, {
filters:[authnFilter, authzFilter,
rateLimitFilter,
analyticsFilter,
extensionFilter]
});
service passthrough on apiListener {
A listener is what a service binds
itself to.
A listener may have one or more
filters to filter requests being
received on the port of the listener.

21.
Ballerina Streams
The RateLimitFilter on the listener
adds metadata of every
successful request into a
data-stream.
public stream<RequestStreamDTO>
requestStream;
public function
publishNonThrottleEvent(RequestStreamDTO
request) {
requestStream.publish(request);
}