tree: 612d637499201c0adb4953ccd275c07c603cd2f5 [path history] [tgz]
  1. .gitignore
  2. main.go
  3. README.md
server/quotabeta/examples/ratelimit/README.md

Quota Library Rate Limit Example

This example shows how to integrate the quota library into a GAE service. Not intended to be run on App Engine. A GAE demo can be found under examples/appengine/quota.

Usage

Startup:

$ go run .&
<observe logs, wait for the server to start>

Verify that rate limiting works:

$ curl http://localhost:8800/global-rate-limit-endpoint
<observe logs, expected 200 OK>
$ curl http://localhost:8800/global-rate-limit-endpoint
<observe logs, expected 429 Rate Limit Exceeded>
<wait 60 seconds>
$ curl http://localhost:8800/global-rate-limit-endpoint
<observe logs, expected 200 OK>

Verify that resetting quota works:

$ curl http://localhost:8800/global-rate-limit-reset
<observe logs, expected 200 OK>
$ curl http://localhost:8800/global-rate-limit-endpoint
<observe logs, expected 200 OK>
$ curl http://localhost:8800/global-rate-limit-endpoint
<observe logs, expected 429 Rate Limit Exceeded>

Verify that multiple resets don't stack:

$ curl http://localhost:8800/global-rate-limit-reset
<observe logs, expected 200 OK>
$ curl http://localhost:8800/global-rate-limit-reset
<observe logs, expected 200 OK>
$ curl http://localhost:8800/global-rate-limit-endpoint
<observe logs, expected 200 OK>
$ curl http://localhost:8800/global-rate-limit-endpoint
<observe logs, expected 429 Rate Limit Exceeded>