我可以撰写变量以在邮递员中创建新的Varibales吗?
我的变量为base_url
。当我使用localhost
时,我将使用一个更多的变量端口
构成它,该端口反映了服务在我本地上运行的端口。这两个变量组成为{{base_url}}:{{port}}
定义了我的API的完整基础URL。
但是,在测试我的API的已部署版本时,我的基本URL只是https://www.xyzapi.com
,而没有任何端口明确声明。
我正在使用{{base_url}}/rule-service/v1/find-by-txn
格式在请求URL中。我正在使用环境在local
和远程
之间切换。
如何在两种情况下都使用相同的请求格式?我有多个在不同端口上运行的微服务。
I have a variable as BASE_URL
. When I am using the localhost
, I am composing it with one more variable PORT
that reflects the port on which the service is running on my local. These two variables composed as {{BASE_URL}}:{{PORT}}
defines the complete base URL for my APIs.
But when testing the deployed version of my API, my base URL is just https://www.xyzapi.com
without any port declared explicitly.
I am using {{BASE_URL}}/rule-service/v1/find-by-txn
format in the request URL. I am using environments to switch between local
and remote
.
How can I utilize the same request format for both cases? I have multiple microservices running on different ports.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该代码完成了工作!
This code did the job!
尝试一下。它引入了variabe
final_base_url
,该将用于构建您的URL(例如{{final_base_url}}/rule-service/rule-service/v1/find-by-txn
)包括端口
是否,取决于设置环境变量port
。Try this. It introduces a variabe
FINAL_BASE_URL
which is to be used to build your URLs (eg{{FINAL_BASE_URL}}/rule-service/v1/find-by-txn
) and it includes thePORT
or not, depending if an environment variablePORT
is set.