我正在使用Ballerina Composer运行我的服务,接着我使用Windows cmd通过curl调用服务,但是cmd提示curl不是一个可识别的命令。在cmd中该怎么做呢?请帮忙解决。
hello_service.bal
。import ballerina/http;
endpoint http:Listener listener {
port:9090
};
service<http:Service> hello bind listener {
sayHello (endpoint caller, http:Request request) {
http:Response response = new;
response.setTextPayload("Hello World!\n");
_ = caller -> respond(response);
}
}
ballerina run hello_service.bal
main.bal
文件。
import ballerina/http;
import ballerina/log;
import ballerina/io;
endpoint http:Client clientEndpoint {
url: "http://localhost:9090"
};
function main(string... args) {
// Send a GET request to the Hello World service endpoint.
var response = clientEndpoint->get("/hello/sayHello");
match response {
http:Response resp => {
io:println(resp.getTextPayload());
}
error err => {
log:printError(err.message, err = err);
}
}
}
ballerina run main.bal
命令。
Hello World!
。