In this article, we are going to cover HTTP services support in the Ballerina programming language (Swan Lake release). We will look at the basics of creating an HTTP service, and then see how the Ballerina language provides a convenient abstraction for defining complex operations as well.

Anatomy of an HTTP Service

A Ballerina service’s structure and its semantics are defined by the service type, i.e. the type of listener attached. Let’s take a look at how a basic HTTP service is structured in Ballerina.

  • Service name: The service name represents the base path of the HTTP service. This is an optional value, where if it’s kept empty, the base path defaults to the value “/”.

  • Listener object: Provides an instance of  http:Listener to bind to a specific host/port.

  • Resource: A resource represents a specific subpath that can be accessed in relation to the service base path.

#services #microservices #ballerina

HTTP Deep-Dive with Ballerina: Services
1.25 GEEK