1

我正在寻找在“getStudentById”资源中动态访问资源的路径。例如,如果服务被称为“ http://localhost:9090/studentfinder/student/0989898 ”。我想要 '/student/0989898' 部分。

 @http:ResourceConfig {
        methods: ["GET"],
        path: "/student/{studentId}"
    }
    getStudentById(endpoint client, http:Request req, string studentId) {
    ...
    }
4

1 回答 1

1

您可以从请求对象获取原始路径,如下所示:

req.rawPath

这应该给出您正在寻找的价值。

https://ballerina.io/learn/api-docs/ballerina/http/objects/Request.html

于 2018-05-22T17:09:28.977 回答