Skip to content

Commit

Permalink
Merge pull request #9686 from ballerina-platform/automate-specs-http-…
Browse files Browse the repository at this point in the history
…b3b053b43244974198b6d40019fb3619207ee410

[AUTOMATE] Update Ballerina Standard Library (http) Specifications
  • Loading branch information
sm1990 authored Jan 31, 2025
2 parents b3b053b + 976e27a commit 9eaa0aa
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
35 changes: 35 additions & 0 deletions public/spec/http/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The conforming implementation of the specification is released and included in t
* 2.1. [Listener](#21-listener)
* 2.1.1. [Automatically starting the service](#211-automatically-starting-the-service)
* 2.1.2. [Programmatically starting the service](#212-programmatically-starting-the-service)
* 2.1.3. [Default listener](#213-default-listener)
* 2.2. [Service](#22-service)
* 2.2.1. [Service type](#221-service-type)
* 2.2.2. [Service-base-path](#222-service-base-path)
Expand Down Expand Up @@ -212,6 +213,40 @@ http:Service s = service object {
};
```

#### 2.1.3. Default listener

The default listener can be created by calling the `getDefaultListener()` method. Once the default listener is created,
the subsequent calls to the `getDefaultListener()` method will return the same listener object. With this approach,
the user can attach multiple services to the same listener and configure the listener as required. The default listener
port is 9090.

```ballerina
import ballerina/http;
listener http:Listener httpListener = http:getDefaultListener();
service /api/v1 on httpListener {
resource function get greeting() returns string {
return "Hello, World from Service 1!";
}
}
```

The port and listener configuration of the default listener can be changed in the `Config.toml` as follows:

```toml
[ballerina.http]
defaultListenerPort = 8080

[ballerina.http.defaultListenerConfig]
httpVersion = "1.1"

[ballerina.http.defaultListenerConfig.secureSocket.key]
path = "resources/certs/ballerinaKeystore.p12"
password = "ballerina"
```

### 2.2. Service
Service is a collection of resources functions, which are the network entry points of a ballerina program.
In addition to that a service can contain public and private functions which can be accessed by calling with `self`.
Expand Down
35 changes: 35 additions & 0 deletions spec/http/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The conforming implementation of the specification is released and included in t
* 2.1. [Listener](#21-listener)
* 2.1.1. [Automatically starting the service](#211-automatically-starting-the-service)
* 2.1.2. [Programmatically starting the service](#212-programmatically-starting-the-service)
* 2.1.3. [Default listener](#213-default-listener)
* 2.2. [Service](#22-service)
* 2.2.1. [Service type](#221-service-type)
* 2.2.2. [Service-base-path](#222-service-base-path)
Expand Down Expand Up @@ -212,6 +213,40 @@ http:Service s = service object {
};
```

#### 2.1.3. Default listener

The default listener can be created by calling the `getDefaultListener()` method. Once the default listener is created,
the subsequent calls to the `getDefaultListener()` method will return the same listener object. With this approach,
the user can attach multiple services to the same listener and configure the listener as required. The default listener
port is 9090.

```ballerina
import ballerina/http;
listener http:Listener httpListener = http:getDefaultListener();
service /api/v1 on httpListener {
resource function get greeting() returns string {
return "Hello, World from Service 1!";
}
}
```

The port and listener configuration of the default listener can be changed in the `Config.toml` as follows:

```toml
[ballerina.http]
defaultListenerPort = 8080

[ballerina.http.defaultListenerConfig]
httpVersion = "1.1"

[ballerina.http.defaultListenerConfig.secureSocket.key]
path = "resources/certs/ballerinaKeystore.p12"
password = "ballerina"
```

### 2.2. Service
Service is a collection of resources functions, which are the network entry points of a ballerina program.
In addition to that a service can contain public and private functions which can be accessed by calling with `self`.
Expand Down

0 comments on commit 9eaa0aa

Please sign in to comment.