ballerina - 我可以访问 Ballerina 程序中的资源路径吗?
问题描述
我正在寻找在“getStudentById”资源中动态访问资源的路径。例如,如果服务被称为“ http://localhost:9090/studentfinder/student/0989898 ”。我想要 '/student/0989898' 部分。
@http:ResourceConfig {
methods: ["GET"],
path: "/student/{studentId}"
}
getStudentById(endpoint client, http:Request req, string studentId) {
...
}
解决方案
您可以从请求对象获取原始路径,如下所示:
req.rawPath
这应该给出您正在寻找的价值。
https://ballerina.io/learn/api-docs/ballerina/http/objects/Request.html
推荐阅读
- python - 如何进行并发线程请求以测试python中URL列表的响应时间
- c++ - 是否有 ifstream 和 ofstream 的宏或缩短 ifstream/ofstream 的方法?
- javascript - 什么是“自定义函数”和“递归”的示例
- node.js - 在 React 项目上编写 Express 服务器
- java - ByteBuddy - 无法从超类拦截静态方法
- javascript - 努力为导航栏添加下拉效果
- python - 仅针对下一个 NaN 行检查项目列表
- stm32 - 带有 STM32f103c8t6 Bluepill 和 CAN 总线的 HAL_CAN_ERROR_PARAM
- python-3.x - 在不使用库的情况下将 CSV 转换为字典
- sql - 如何跨多列选择最后三个非空列