diff options
author | Loïc Hoguin <[email protected]> | 2018-11-04 11:51:35 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-11-04 11:58:59 +0100 |
commit | 8c9ad7bf078871295e391f416bfcb10c9156a35f (patch) | |
tree | f92cf4f4ff6f978405cf8171e86b44de27f91265 /doc/src/manual | |
parent | bf7ccc8623610d34cf3323db776b280a50275678 (diff) | |
download | cowboy-8c9ad7bf078871295e391f416bfcb10c9156a35f.tar.gz cowboy-8c9ad7bf078871295e391f416bfcb10c9156a35f.tar.bz2 cowboy-8c9ad7bf078871295e391f416bfcb10c9156a35f.zip |
Add the rate_limited/2 REST callback
Diffstat (limited to 'doc/src/manual')
-rw-r--r-- | doc/src/manual/cowboy_rest.asciidoc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/src/manual/cowboy_rest.asciidoc b/doc/src/manual/cowboy_rest.asciidoc index dd5fa7e..4babcc5 100644 --- a/doc/src/manual/cowboy_rest.asciidoc +++ b/doc/src/manual/cowboy_rest.asciidoc @@ -603,6 +603,30 @@ release. // @todo Add a way to switch to loop handler for streaming the body. +=== rate_limited + +[source,erlang] +---- +rate_limited(Req, State) -> {Result, Req, State} + +Result :: false | {true, RetryAfter} +RetryAfter :: non_neg_integer() | calendar:datetime() +Default - false +---- + +Return whether the user is rate limited. + +This function can be used to temporarily restrict +access to a resource when the user has issued too +many requests. + +When the resource is rate limited the `RetryAfter` +value will be sent in the retry-after header for the +'429 Too Many Requests' response. It indicates when +the resource will become available again and can be +specified as a number of seconds in the future or a +specific date/time. + === resource_exists [source,erlang] @@ -696,6 +720,7 @@ listed here, like the authorization header. == Changelog +* *2.6*: The callback `rate_limited` was added. * *2.1*: The `switch_handler` return value was added. * *1.0*: Behavior introduced. |