mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 18:19:52 +01:00
Rate Limit headers
This commit is contained in:
parent
62d53fab7e
commit
4e25a0273b
3 changed files with 11 additions and 8 deletions
4
Gemfile
4
Gemfile
|
@ -75,13 +75,11 @@ gem 'grape'
|
||||||
gem 'wine_bouncer'
|
gem 'wine_bouncer'
|
||||||
gem 'grape-entity'
|
gem 'grape-entity'
|
||||||
gem 'grape-msgpack'
|
gem 'grape-msgpack'
|
||||||
gem 'grape-throttle'
|
gem 'grape-throttle', git: 'https://github.com/Retrospring/grape-throttle.git'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# require spring 1.3.5 since shit's on fire on my local instance with 1.3.4 (Gem::LoadError)
|
# require spring 1.3.5 since shit's on fire on my local instance with 1.3.4 (Gem::LoadError)
|
||||||
# gem 'spring', '~> 1.3.5'
|
# gem 'spring', '~> 1.3.5'
|
||||||
# holy shit spring is terrible
|
|
||||||
# ten thousand raises no more!
|
|
||||||
gem 'byebug'
|
gem 'byebug'
|
||||||
gem 'web-console'
|
gem 'web-console'
|
||||||
gem 'quiet_assets'
|
gem 'quiet_assets'
|
||||||
|
|
13
Gemfile.lock
13
Gemfile.lock
|
@ -1,3 +1,11 @@
|
||||||
|
GIT
|
||||||
|
remote: https://github.com/Retrospring/grape-throttle.git
|
||||||
|
revision: fc7b997990b2d04c31e97a4b458fde996aa63253
|
||||||
|
specs:
|
||||||
|
grape-throttle (0.0.4)
|
||||||
|
grape (>= 0.10.0)
|
||||||
|
redis
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/retrospring/questiongenerator.git
|
remote: https://github.com/retrospring/questiongenerator.git
|
||||||
revision: 902de3d7f930a4f67bbbbc414cc3556cc7114839
|
revision: 902de3d7f930a4f67bbbbc414cc3556cc7114839
|
||||||
|
@ -239,9 +247,6 @@ GEM
|
||||||
grape-msgpack (0.1.2)
|
grape-msgpack (0.1.2)
|
||||||
grape (>= 0.6.0)
|
grape (>= 0.6.0)
|
||||||
msgpack (~> 0.5.6)
|
msgpack (~> 0.5.6)
|
||||||
grape-throttle (0.0.1)
|
|
||||||
grape (>= 0.10.0)
|
|
||||||
redis
|
|
||||||
haml (4.0.6)
|
haml (4.0.6)
|
||||||
tilt
|
tilt
|
||||||
hashie (3.4.1)
|
hashie (3.4.1)
|
||||||
|
@ -558,7 +563,7 @@ DEPENDENCIES
|
||||||
grape
|
grape
|
||||||
grape-entity
|
grape-entity
|
||||||
grape-msgpack
|
grape-msgpack
|
||||||
grape-throttle
|
grape-throttle!
|
||||||
haml
|
haml
|
||||||
i18n-js
|
i18n-js
|
||||||
jbuilder (~> 2.2.4)
|
jbuilder (~> 2.2.4)
|
||||||
|
|
|
@ -79,7 +79,7 @@ class API < Grape::API
|
||||||
|
|
||||||
use ::WineBouncer::OAuth2
|
use ::WineBouncer::OAuth2
|
||||||
|
|
||||||
use Grape::Middleware::ThrottleMiddleware, cache: Redis.new(url: APP_CONFIG['redis_url']), user_key: ->(env) do
|
use Grape::Middleware::ThrottleMiddleware, expires_header: 'X-Rate-Limit-Reset', limit_header: 'X-Rate-Limit-Limit', remaining_header: 'X-Rate-Limit-Remaining', cache: Redis.new(url: APP_CONFIG['redis_url']), user_key: ->(env) do
|
||||||
context = env['api.endpoint']
|
context = env['api.endpoint']
|
||||||
user = unless context.current_token.nil?
|
user = unless context.current_token.nil?
|
||||||
"app:#{context.current_application.id}user:#{context.current_user.id}"
|
"app:#{context.current_application.id}user:#{context.current_user.id}"
|
||||||
|
|
Loading…
Reference in a new issue