import ballerina/http;
service / on new http:Listener(9090) {
// This function responds with `string` value `Hello, World!` to HTTP GET requests.
resource function get greeting() returns string {
return "Hello, World!";
}
}
Hello world serviceLet’s write a simple HTTP service in Ballerina. This example demonstrates the network primitives in the language that make it simpler to develop services. |
import ballerina/http;
service / on new http:Listener(9090) {
resource function get greeting() returns string {
return "Hello, World!";
}
This function responds with string
value Hello, World!
to HTTP GET requests.
}
bal run hello_world_service.bal
# Invoke the service using the "cURL" command below.
curl http://localhost:9090/greeting
Hello, World!