Modules

http

http.default

tharmigank/http.default

0.4.0

Overview

This module provides a built-in HTTP listener that serves as the default listener for attaching HTTP servers. It supports the attachment of multiple services, making it ideal for centralized deployment. Additionally, it allows for the customization of its port and configuration, offering versatility for various use cases.

Usage Example

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

Copy
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.4.0


Compatibility

Platform: any

Ballerina version: 2201.10.3

GraalVM compatible: Yes


Pull count

Total: 4

Current verison: 0


Weekly downloads


Other versions

See more...