如何从 google 云端点获取远程 IP 地址?

How to get the remote ip address from google cloud endpoint?

我正在尝试检查 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);
}

来自这个post:

@ApiMethod(name = "echo")
public Message echo(HttpServletRequest req, Message message, @Named("n") @Nullable Integer n) {

  String remote = req.getRemoteAddr();

  return doEcho(message, n);
}

感谢@ikerlasaga