Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rate limit count and remaining time limit. #2081

Closed
wants to merge 1 commit into from

Commits on Jan 22, 2024

  1. Get rate limit count and remaining time limit.

    // Simple example...
    .get("/", ctx -> {
        NaiveRateLimit.requestPerTimeUnit(ctx, 5, TimeUnit.MINUTES);
        ConcurrentHashMap<TimeUnit, RateLimiter> limiters = RateLimitUtil.INSTANCE.getLimiters();
        int count = limiters.get(TimeUnit.MINUTES).getCounter(ctx);
        long remainder = limiters.get(TimeUnit.MINUTES).getRemainder(TimeUnit.MILLISECONDS);
    
        ctx.result("Count: " + count + " Remainder: " + remainder);
    })
    p4paul committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    538e70e View commit details
    Browse the repository at this point in the history