mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 16: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 'grape-entity'
|
||||
gem 'grape-msgpack'
|
||||
gem 'grape-throttle'
|
||||
gem 'grape-throttle', git: 'https://github.com/Retrospring/grape-throttle.git'
|
||||
|
||||
group :development do
|
||||
# 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'
|
||||
# holy shit spring is terrible
|
||||
# ten thousand raises no more!
|
||||
gem 'byebug'
|
||||
gem 'web-console'
|
||||
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
|
||||
remote: https://github.com/retrospring/questiongenerator.git
|
||||
revision: 902de3d7f930a4f67bbbbc414cc3556cc7114839
|
||||
|
@ -239,9 +247,6 @@ GEM
|
|||
grape-msgpack (0.1.2)
|
||||
grape (>= 0.6.0)
|
||||
msgpack (~> 0.5.6)
|
||||
grape-throttle (0.0.1)
|
||||
grape (>= 0.10.0)
|
||||
redis
|
||||
haml (4.0.6)
|
||||
tilt
|
||||
hashie (3.4.1)
|
||||
|
@ -558,7 +563,7 @@ DEPENDENCIES
|
|||
grape
|
||||
grape-entity
|
||||
grape-msgpack
|
||||
grape-throttle
|
||||
grape-throttle!
|
||||
haml
|
||||
i18n-js
|
||||
jbuilder (~> 2.2.4)
|
||||
|
|
|
@ -79,7 +79,7 @@ class API < Grape::API
|
|||
|
||||
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']
|
||||
user = unless context.current_token.nil?
|
||||
"app:#{context.current_application.id}user:#{context.current_user.id}"
|
||||
|
|
Loading…
Reference in a new issue