tharmigank/http.default

0.23.0

Overview

This module provides a built-in HTTP listener that serves as the default implementation for creating HTTP servers. It allows multiple services to be attached and supports customization of its port and configuration, making it versatile for various use cases.

Key Features

  • Built-in listener for convenient HTTP service setup.
  • Supports attaching multiple services, making it suitable for centralized deployment.
  • Fully customizable port and listener configuration.

Usage Example

The following example demonstrates how to use the default HTTP listener to create an HTTP server:

import ballerina/http.default;

service /api on default:httpListener {

resource function get greeting() returns string {
    return "Hello, World!";
}

}

Customizing the Listener Port

By default, the listener uses port 9090. To change this, specify the desired port in the Config.toml file as shown below:

Copy
[ballerina.http.default]
listenerPort = 8080

Configuring the Listener

You can customize all HTTP listener configuration in the Config.toml file. For detailed instructions on configuring variables, refer to the Configurability guide.

The following example configures the HTTP listener to use HTTP/1.1 and enables SSL:

Copy
[ballerina.http.default.listenerConfig]
httpVersion = "1.1"

[ballerina.http.default.listenerConfig.secureSocket.key]
path = "resources/certs/key.pem"
password = "password"

Import

import tharmigank/http.default;Copy

Metadata

Released date: 4 months ago

Version: 0.23.0


Compatibility

Platform: any

Ballerina version: 2201.10.3

GraalVM compatible: Yes


Pull count

Total: 4

Current verison: 1


Weekly downloads


Other versions

See more...