【问题标题】:Can I access resource path in Ballerina program?我可以访问 Ballerina 程序中的资源路径吗?
【发布时间】:2018-05-22 16:24:48
【问题描述】:

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

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

【问题讨论】:

    标签: ballerina


    【解决方案1】:

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

    req.rawPath
    

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-31
      • 2017-02-19
      • 1970-01-01
      相关资源
      最近更新 更多