Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

RateLimitter

nftablesのlimit rateのような単位時間内でのアクセス数制限を行うクラスの実装です。

実装例

@RestController
public class HelloController {
    private static RateLimitter limitter = new RateLimitter();

    @Autowired
    HttpServletRequest request;

    @GetMapping("/")
    public String index() {
        if (!limitter.allowAccess(request.getRemoteAddr(), System.currentTimeMillis())) {
            throw new ResponseStatusException(HttpStatus.TOO_MANY_REQUESTS);
        }
        // DO BUSINESS LOGIC
    }
}

About

No description, website, or topics provided.

Resources

License

Releases

No releases published

Packages

No packages published

Languages