Skip to content

Commit

Permalink
Merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
warunalakshitha committed Jan 23, 2025
2 parents 24ba264 + f67de08 commit 82152a0
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 17 deletions.
5 changes: 5 additions & 0 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ name = "http.httpscerr"
description = "This module provides status code error types."
export = true

[[package.modules]]
name = "http.default"
description = "This module provides the default HTTP listener."
export = true

[platform.java21]
graalvmCompatible = true

Expand Down
1 change: 1 addition & 0 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ dependencies = [
]
modules = [
{org = "ballerina", packageName = "http", moduleName = "http"},
{org = "ballerina", packageName = "http", moduleName = "http.default"},
{org = "ballerina", packageName = "http", moduleName = "http.httpscerr"}
]

Expand Down
42 changes: 42 additions & 0 deletions ballerina/modules/default/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## 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:

```ballerina
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:

```toml
[ballerina.http.default]
listenerPort = 8080
```

## Configuring the Listener

You can customize all [HTTP listener configuration](https://central.ballerina.io/ballerina/http/latest#ListenerConfiguration) in the `Config.toml` file. For detailed instructions on configuring variables, refer to the [Configurability](https://ballerina.io/learn/provide-values-to-configurable-variables/) guide.

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

```toml
[ballerina.http.default.listenerConfig]
httpVersion = "1.1"

[ballerina.http.default.listenerConfig.secureSocket.key]
path = "resources/certs/key.pem"
password = "password"
```
27 changes: 27 additions & 0 deletions ballerina/modules/default/listener.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2025 WSO2 Inc. (http://www.wso2.org).
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/http;

# Represents the port that the default HTTP listener should be bound to.
# The default port is 9090
public configurable int listenerPort = 9090;

# Represents the listener configuration that should be used by the default HTTP listener
public configurable http:ListenerConfiguration listenerConfig = {};

# Represents the default HTTP listener that can be used by multiple services
public listener http:Listener httpListener = check new (listenerPort, listenerConfig);
5 changes: 5 additions & 0 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ name = "http.httpscerr"
description = "This module provides status code error types."
export = true

[[package.modules]]
name = "http.default"
description = "This module provides the default HTTP listener."
export = true

[platform.java21]
graalvmCompatible = true

Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [Add static code rules](https://github.com/ballerina-platform/ballerina-library/issues/7283)
- [Add relax data binding support for service and client data binding](https://github.com/ballerina-platform/ballerina-library/issues/7366)
- [Add support for configuring server name to be used in the SSL SNI extension](https://github.com/ballerina-platform/ballerina-library/issues/7435)
- [Add default HTTP listener](https://github.com/ballerina-platform/ballerina-library/issues/7514)

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions docs/spec/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The conforming implementation of the specification is released and included in t
* 2.2.4. [Service class declaration](#224-service-class-declaration)
* 2.2.5. [Service constructor expression](#225-service-constructor-expression)
* 2.2.6. [Service contract type](#226-service-contract-type)
* 2.2.7. [Relaxed data binding](#227-relaxed-data-binding)
* 2.3. [Resource](#23-resource)
* 2.3.1. [Accessor](#231-accessor)
* 2.3.2. [Resource-name](#232-resource-name)
Expand Down Expand Up @@ -59,6 +60,7 @@ The conforming implementation of the specification is released and included in t
* 2.4.1.7. [Load balance](#2417-load-balance)
* 2.4.1.8. [Failover](#2418-failover)
* 2.4.1.9. [Status code binding client](#2419-status-code-binding-client)
* 2.4.1.10. [Relaxed data binding client](#24110-relaxed-data-binding-client)
* 2.4.2. [Client actions](#242-client-action)
* 2.4.2.1. [Entity body methods](#2421-entity-body-methods)
* 2.4.2.2. [Non entity body methods](#2422-non-entity-body-methods)
Expand Down
34 changes: 17 additions & 17 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.caching=true
group=io.ballerina.stdlib
version=2.13.0-SNAPSHOT
ballerinaLangVersion=2201.11.0-20250109-162500-c85851f4
ballerinaLangVersion=2201.11.0-20250121-140200-15de3b28
ballerinaTomlParserVersion=1.2.2
commonsLang3Version=3.12.0
nettyVersion=4.1.115.Final
Expand Down Expand Up @@ -31,27 +31,27 @@ githubJohnrengelmanShadowVersion=8.1.1
underCouchDownloadVersion=5.4.0
researchgateReleaseVersion=2.8.0

stdlibIoVersion=1.7.0-20241218-111600-1da6a3f
stdlibTimeVersion=2.6.0-20241218-111600-f57d32a
stdlibUrlVersion=2.5.0-20241218-111600-4f962bc
stdlibIoVersion=1.7.0-20250121-143700-fac534d
stdlibTimeVersion=2.6.0-20250121-143700-96fbd6a
stdlibUrlVersion=2.5.0-20250121-143700-9db47c2

stdlibConstraintVersion=1.6.0-20241218-112400-cd313f2
stdlibOsVersion=1.9.0-20241218-112400-c81f077
stdlibTaskVersion=2.6.0-20241218-112900-84f2aea
stdlibLogVersion=2.11.0-20241218-115100-06c729e
stdlibCryptoVersion=2.8.0-20241218-112400-d6f4922
stdlibConstraintVersion=1.6.0-20250121-144400-48092bd
stdlibOsVersion=1.9.0-20250121-144400-3c22e13
stdlibTaskVersion=2.6.0-20250121-144900-6de8c93
stdlibLogVersion=2.11.0-20250121-151200-196ede7
stdlibCryptoVersion=2.8.0-20250121-144400-cf0d2db

stdlibFileVersion=1.11.0-20241218-125000-364d941
stdlibMimeVersion=2.11.0-20241218-125100-e28a03b
stdlibCacheVersion=3.9.0-20241218-114600-9f52392
stdlibFileVersion=1.11.0-20250122-120300-6dd5c6c
stdlibMimeVersion=2.11.0-20250122-120300-9005c8c
stdlibCacheVersion=3.9.0-20250121-150600-d24d690

stdlibAuthVersion=2.13.0-20241218-124900-9203135
stdlibAuthVersion=2.13.0-20250122-120100-293d482
stdlibDataJsonDataVersion=1.0.0-20241125-114000-0c2f457
stdlibJwtVersion=2.14.0-20241218-125000-c952d1e
stdlibOAuth2Version=2.13.0-20241218-125400-c7625c1
stdlibJwtVersion=2.14.0-20250122-120200-9a7dd9b
stdlibOAuth2Version=2.13.0-20250122-120600-a9c21e1

balScanVersion=0.5.0

observeVersion=1.4.0-20241218-111700-4d29d40
observeInternalVersion=1.4.0-20241218-112700-be9da2c
observeVersion=1.4.0-20250121-143800-aa6fa02
observeInternalVersion=1.4.0-20250121-144700-d59c066

0 comments on commit 82152a0

Please sign in to comment.