rack-ratelimit 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rack/ratelimit.rb +6 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73b500a4dca2655841490da8c02106a49f69f62b
4
- data.tar.gz: 265204cbba7c818c0190eee355d55a7147083d1a
3
+ metadata.gz: e01063bca7c6d18ab0206611063a339dc7ddfad6
4
+ data.tar.gz: ffb944f15efc8239948306e4948f25c8d488e07c
5
5
  SHA512:
6
- metadata.gz: da84278754fd180b780687f5819f4847d2e8fcf49378029e023b95706324b3b06eedd5cedf1c3b453e26723ed8b409ea78799e190497076db3411be9f9f55081
7
- data.tar.gz: 2af1a03a36288b8cbec652185ff1207b3e9052b58d3c0737c7a07159f349eeadaacf42c79acfde8ad2ae8a46f011b61fd04619d21b629117ae1f059ec4e9d7b3
6
+ metadata.gz: b64f78b469c570ade7cb6f03e301c70550adb7486b3e5a2e36de522db35d80ce769ddd7f18e18274c6a5a6da2a2a5224244268a2a6378e5e9f8e91228ab6e7b7
7
+ data.tar.gz: 0b4929fb74cd3da4a727e1ef5c0e5fbf160704e06be4e4e639df7be98e28f1dd6dada78918bd72cd2ee85d17efceb57cb123223777fda4b83a59dbcb27f7c763
@@ -92,6 +92,11 @@ module Rack
92
92
  @exceptions.none? { |e| e.call(env) } && @conditions.all? { |c| c.call(env) }
93
93
  end
94
94
 
95
+ # Give subclasses an opportunity to specialize classification.
96
+ def classify(env)
97
+ @classifier.call env
98
+ end
99
+
95
100
  # Handle a Rack request:
96
101
  # * Check whether the rate limit applies to the request.
97
102
  # * Classify the request by IP, API token, etc.
@@ -101,7 +106,7 @@ module Rack
101
106
  # * If it's the first request that exceeds the limit, log it.
102
107
  # * If the count doesn't exceed the limit, pass through the request.
103
108
  def call(env)
104
- if apply_rate_limit?(env) && classification = @classifier.call(env)
109
+ if apply_rate_limit?(env) && classification = classify(env)
105
110
 
106
111
  # Marks the end of the current rate-limiting window.
107
112
  timestamp = @period * (Time.now.to_f / @period).ceil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-ratelimit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Kemper