服务端函数增加获取客户端IP地址途径
JasonHonor opened this issue · 2 comments
JasonHonor commented
Feature Request
Crates
volo-thrift v0.9.2
Motivation
示例代码在Server端生成的服务函数get_item函数,需要增加客户端IP地址信息。
Proposal
用于关注客户端地址的业务应用,如:接口的IP白名单等。
Alternatives
PureWhiteWu commented
可以增加一个中间件,在中间件中通过 cx.rpc_info().caller().address() 获取试试?
JasonHonor commented
多谢,将示例的中间件LogService中的cx改为 Send+'static+ volo::context::Context, 调用cx.rpc_info().caller().address()可以获取到客户端的IP和端口。