Code Monkey home page Code Monkey logo

grape-attack's People

Contributors

davidcollom avatar gottfrois avatar tpope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

grape-attack's Issues

TypeError (no implicit conversion of String into Integer):

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:inafter'
grape (0.14.0) lib/grape/middleware/base.rb:26:in call!' grape (0.14.0) lib/grape/middleware/base.rb:19:incall'
....

how can we add/send status with no response....

How does it compare to Rack::Attack?

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.

Documentation

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.

Rate Limiting resetting not working as intended

Each time the key gets updated, the expiry is reset (see here).

What is happening

  1. Setup endpoint that allows 100 requests per 1 day
  2. Make 90 requests in 1 hour (at time 00:00)
  3. 22 hours later make 9 more requests (at time 22:00)
  4. 3 hours after that make 2 requests (at time 01:00 the next day)

The last request will be rate limited.

What should be happening

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.

How can I supply max and per parameters to throttle from activerecord query

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

A question

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?

Issue with grape - 0.15.0

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!

undefined method '[]' for nil:NilClass

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.