gottfrois / grape-attack Goto Github PK
View Code? Open in Web Editor NEWA middleware for Grape to add endpoint-specific throttling.
License: MIT License
A middleware for Grape to add endpoint-specific throttling.
License: MIT License
When response is empty and adding only status code -
status :no_content OR status 204
Getting below error -
TypeError (no implicit conversion of String into Integer):
grape-attack (0.2.0) lib/grape/attack/throttle.rb:20:in []=' grape-attack (0.2.0) lib/grape/attack/throttle.rb:20:in
after'
grape (0.14.0) lib/grape/middleware/base.rb:26:in call!' grape (0.14.0) lib/grape/middleware/base.rb:19:in
call'
....
how can we add/send status with no response....
From the readme, it seems like this gem is doing something very similar to Rack::Attack. Since Rack::Attack is an already well-known gem, and it can be used in any Rack application (not just for Grape), I think it wold be good to add to the readme what are some of the advantages of using Grape::Attack over Rack::Attack in Grape applications.
Hi there, saw this on Ruby Weekly. Looks cool!
Would you consider providing some documentation on how this works? At first glance, it seems like it's counting the requests in memory. How would that work in app servers that are, often, multi-thread or multi-process? Examples are Unicorn, Puma, and Passenger.
Each time the key gets updated, the expiry is reset (see here).
The last request will be rate limited.
In the example above, 24 hours after the first request (midnight on the second day) the rate limiting should have been reset. At step 4, there should be 100 remaining requests available, however there is only 1.
I am using following code but it does not takes the values of max and per when i change it, untill I restart the rails server. due to which even if change the values of max_no_of_requests and time_period_in_secs for a particular api in database throttle still uses old max and per untill i restart server.
throttle max: ApiConfig.where(api_code_name: 'get_users').select(:max_no_of_requests).first.max_no_of_requests, per: ApiConfig.where(api_code_name: 'get_users').select(:time_period_in_secs).first.time_period_in_secs.seconds
Please look into this and suggest how can pick the max and per values using a activerecord query
Hi,
How to gracefully handle this error - Grape::Attack::RateLimitExceededError. Its increasing error rate on newrelic.
Anybody facing the same issue?
Thanks,
Shan
thing like this no longer works with latest grape:
throttle max: 5, per: 1.day, identifier: Proc.new { params[:id] }
because params[:id] always return nil in a before filter.
I am using Grape for my API and wonder if it is anyway to use this and have different throttling rules for different types of users. Based on if they are VIP or not.
Do you know I can do that?
Hey,
Looks the newer version of grape is creating an issue with grape-attack 0.2.0. I recently ran
bundle update
and it updated me to grape - 0.15.0 and I was getting the error
NoMethodError in after callback inside Grape::Attack::Throttle : undefined method `[]=' for nil:NilClass
And eventually after about 2 hours, I figured it out and added version to Gemfile
and ran
bundle update grape
.
Everything is fine now but looks something is broken.
I'd be happy to share the trace and my Gemfile.lock.
Please look into this!
Hi @gottfrois!
I am trying to implement grape-attack to my api now.
i get this error when i add use Grape::Attack::Throttle
to Apiv2 class
F, [2015-11-25T20:19:56.890773 #11763] FATAL -- :
NoMethodError (undefined method `[]' for nil:NilClass):
app/api/apiv2.rb:22:in `apitoken'
app/api/v2/stations/stations.rb:30:in `block (2 levels) in <class:Stations>'
apiv2.rb:22:
def apitoken
Apikey.eager_load(:User).where(apikey: params[:token]).first
end
As soon as I commenting use Grape::Attack::Throttle
it works again.
What can be the issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.