您好,我正在使用Java拦截器,并想确定调用api的客户端ip地址
Open Api规范
paths:
/test:
get:
description: ""
operationId: PING
x-wso2-disable-security: true
x-wso2-throttling-tier: 6PerMin
x-wso2-request-interceptor: java:org.mgw.interceptor.IDSAuthInterceptor
responses:
"200":
description: Successful response
content:
application/json:
schema:
$ref: "#/components/schemas/PING"
application/xml:
schema:
$ref: "#/components/schemas/PING"
security:
- basicAuthentication: []
Java拦截器
public class IDSAuthInterceptor implements Interceptor {
public boolean interceptRequest(Caller caller, Request request) {
// How to determine client ip. Not able to fetch using {Caller caller, Request request}
}
}
答案 0 :(得分:0)
有两个选项。
从请求中,您可以查找标头值[1]。
caller.getRemoteAddress()
芭蕾舞女演员方面似乎有一个问题,该问题未返回IP地址。