import ballerina/http;
// Service declaration specifies base path for the resource names. The base path is `/` in this example.
service / on new http:Listener(8080) {
// Resource method is associated with combination of accessor (`get`) and resource name (`hello`).
// Accessors are determined by the network protocol.
// In HTTP resources, function parameters come from query parameters.
resource function get hello(string name) returns string {
return "Hello, " + name;
}
}
Resource methodsService objects use |
import ballerina/http;
service / on new http:Listener(8080) {
Service declaration specifies base path for the resource names. The base path is /
in this example.
resource function get hello(string name) returns string {
return "Hello, " + name;
}
Resource method is associated with combination of accessor (get
) and resource name (hello
).
Accessors are determined by the network protocol.
In HTTP resources, function parameters come from query parameters.
}
bal run resource_methods.bal
# Run this cURL command to invoke the resource.
curl "localhost:8080/hello?name=Ballerina"
Hello, Ballerina