Rate limiting doesn't provide protection against real DoS attacks, it only provides protection against legitimate users who are abusing your service, eg users trying to scrape all the data out of your site, they're doing the wrong thing but it's not their intention to bring your site down, so it's not really a DoS attack. While Play could provide some abstractions here, these abstractions would be no simpler than implementing an ordinary filter, which would make them more complex since any time you introduce an abstraction, you make things harder to debug and reason about. So, if you want per remote IP address rate limiting, a simple filter like this will work:
object MyRateLimiterFilter extends EssentialFilter {
def apply(action: EssentialAction) = EssentialAction { rh =>
val exceeded = RateLimiter.registerRequest(rh.remoteAddress)
if (exceeded) Done(Results.Status(429))
else next(rh)
}
}
Of course, you might find that if you have 100 people in one company behind a NAT firewall, they start getting blocked. Same with many mobile users on one mobile network. So this usually won't work, instead you need to check if they are authenticated, and that's when it becomes very domain specific and when abstractions get in your way.
Also note, Play is nowhere near as susceptible to DoS attacks as traditional HTTP servers, since it does not consume a thread per request - for traditional HTTP servers which use a thread per request model, you can very easily DoS them by making 300 requests but trickle feeding/trickling reading the request/response bodies. If the server is only configured to use 300 threads, the server stops responding. But a Play server will happily accept hundreds of thousands of such requests, and still be just as responsive.
As others have said, if you really are up against an attack (and not just legitimate users abusing your service), if the requests are getting through to Play in the first place, then you're probably screwed on network bandwidth for a start, real DDoS attacks can only be dealt with with specialised software (and often hardware).