我正在尝试检查调用者是否针对Google Cloud Endpoint中的方法 白名单。如何获取客户端的远程地址? (以及如何获取请求对象?)
更新:感谢@ikerlasaga:
@ApiMethod(name = "echo")
public Message echo(HttpServletRequest req, Message message, @Named("n") @Nullable Integer n) {
String remote = req.getRemoteAddr();
return doEcho(message, n);
}
答案 0 :(得分:1)
来自此帖子:Getting raw HTTP Data (Headers, Cookies, etc) in Google Cloud Endpoints
@ApiMethod(name = "echo")
public Message echo(HttpServletRequest req, Message message, @Named("n") @Nullable Integer n) {
String remote = req.getRemoteAddr();
return doEcho(message, n);
}
感谢@ikerlasaga