aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide
diff options
context:
space:
mode:
authorTom Christie2012-09-14 08:54:58 +0100
committerTom Christie2012-09-14 08:54:58 +0100
commit886f8b47510c830483b5adae1855593cdc3df2dc (patch)
tree4e81ac5bdd42b48a22b506dd8f317c505d8a128d /docs/api-guide
parent3005079824949534ff55f6342d01953a5bed9638 (diff)
downloaddjango-rest-framework-886f8b47510c830483b5adae1855593cdc3df2dc.tar.bz2
Tweak throttles and improve docs
Diffstat (limited to 'docs/api-guide')
-rw-r--r--docs/api-guide/throttling.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/api-guide/throttling.md b/docs/api-guide/throttling.md
index 0856183b..d1e34dcd 100644
--- a/docs/api-guide/throttling.md
+++ b/docs/api-guide/throttling.md
@@ -83,6 +83,29 @@ The allowed request rate is determined from one of the following (in order of pr
* The `rate` property on the class, which may be provided by overriding `UserThrottle` and setting the property.
* The `DEFAULT_THROTTLE_RATES['user']` setting.
+An API may have multiple `UserRateThrottles` in place at the same time. To do so, override `UserRateThrottle` and set a unique "scope" for each class.
+
+For example, multiple user throttle rates could be implemented by using the following classes...
+
+ class BurstRateThrottle(UserRateThrottle):
+ scope = 'burst'
+
+ class SustainedRateThrottle(UserRateThrottle):
+ scope = 'sustained'
+
+...and the following settings.
+
+ API_SETTINGS = {
+ 'DEFAULT_THROTTLES': (
+ 'example.throttles.BurstRateThrottle',
+ 'example.throttles.SustainedRateThrottle',
+ )
+ 'DEFAULT_THROTTLE_RATES': {
+ 'burst': '60/min',
+ 'sustained': '1000/day'
+ }
+ }
+
`UserThrottle` is suitable if you want a simple global rate restriction per-user.
## ScopedRateThrottle