0

我正在使用播放!1.2.5,我不确定我设计的方法是不是最好的方法!

我想将应用程序接受的请求限制为仅从代理机器接收到的请求。

我在 中找不到这样的功能,application.conf所以我编写了一个插件来在调用每个操作之前检查 IP 地址:

public class MyPlugin extends PlayPlugin {

  @Override
  public void beforeActionInvocation(Method method) {
    System.out.println("\naction: " + method.getName());
    String ip = Http.Request.current.get().remoteAddress;
    ip = ip.trim();    
    System.out.println("\nIP: " + ip);

    if (!ip.equals("x.x.x.x")) {
      // i don't know how to stop invocation of ActionMethod 
    }
  }
}

现在,如果是正确的方法,当IP地址不是代理机IP地址时,如何停止调用action方法?

4

0 回答 0