NAME Plack::Middleware::APIRateLimit - A Plack Middleware for API Throttling SYNOPSIS my $handler = builder { enable "APIRateLimit"; # or enable "APIRateLimit", requests_per_hour => 2, backend => "Hash"; # or enable "APIRateLimit", requests_per_hour => 2, backend => ["Redis", {port => 6379, server => '127.0.0.1'}]; # or enable "APIRateLimit", request_per_hour => 2, backend => Redis->new(server => '127.0.0.1:6379'); sub { [ '200', [ 'Content-Type' => 'text/html' ], ['hello world'] ] }; }; DESCRIPTION Plack::Middleware::APIRateLimit is a Plack middleware for controlling API access. Set a limit on how many requests per hour is allowed on your API. In the case of a authorized request, 3 headers are added: X-RateLimit-Limit How many requests are authorized by hours X-RateLimit-Remaining How many remaining requests X-RateLimit-Reset When will the counter be reseted (in epoch) VARIABLES backend Which backend to use. Currently only Hash and Redis are supported. If no backend is specified, Hash is used by default. Backend must implement set, get and incr. requests_per_hour How many requests is allowed by hour. AUTHOR franck cuny SEE ALSO LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.