Limit request on a Restlet resource with APISpark restlet extension

前端 未结 2 1052
北海茫月
北海茫月 2021-01-27 11:33

Here\'s my code to limit the number of request for minute:

        MethodAuthorizer ma = createMethodAuthorizer();
        ma.setNext(router);

        FirewallR         


        
2条回答
  •  心在旅途
    2021-01-27 12:03

    you can also rely on the ApisparkService (I've tested it using the release v2.3.2) of the framework:

    public TestApplication() {
        super();
        ApiSparkService as = new ApiSparkService();
        as.setFirewallEnabled(true);
        as.getFirewallConfig().addIpAddressesPeriodicCounter(60, TimeUnit.SECONDS, 10);
        getServices().add(as);
    }
    

提交回复
热议问题