1

假设我的服务器收到了一个 GET 请求

www.example.com/?hub.mode=subscribe&hub.challenge=1320729329&hub.verify_token=你好

我想回应部分 hub.challenge 回来。我怎样才能用芭蕾舞女演员的语言做到这一点?

4

1 回答 1

1

您需要为此使用@http:QueryParams。请参考以下示例:

import ballerina.net.http;
import ballerina.lang.system;

@http:BasePath {value:"/shop"}
service echo {

    @http:GET{}
    @http:Path {value:"/order"}
    resource echoGet (message m, @http:QueryParam {value:"orderid"}string orderid) {
        system:println("orderid" + orderid);
        reply m;

    }
}

作为http://localhost:9090/shop/order?orderid=123的 GET 请求将被设置为 variable orderid,然后您可以在进一步的实现中使用它。(请注意我用于system:println示例目的)

于 2017-06-17T11:14:13.440 回答