rails_api_guard 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7b4d8d394e924a76d3aa00b2fdb2fdf782747545d8ffc2542506bc854ea6a65
4
- data.tar.gz: 9dfa228e433502c43df3e0ed50348af2581c73cfa7376d88e1a491310ca8eac5
3
+ metadata.gz: 93890693de684b76c7ac78ed99e9d1ca804272c7cbf14b1c8087d5070ab2fcea
4
+ data.tar.gz: f4056a7057f5d56e26143ebf7d810d2d742090a2e920c4cf29a9b289bea96924
5
5
  SHA512:
6
- metadata.gz: dc940368929aa36574ff9fac9326eaf2c2d6a104c42081491bf0552857becbfb5ae9dbe51f2fc63f518f5ad771e59f63ac3ed1c0b8f37fdf20c91de17ca06906
7
- data.tar.gz: 94144edae5b36b29d9319d152a1d80b95d524f9e66e9b22d8880805baf74f692e6645cf051e352442a4b698698d7056011d9a0263cafaeed502d75e5c3977791
6
+ metadata.gz: a4b8acff3abc11669ad3d6ca6a1d35886e06f420f51f27822d6292e942b920b10faccfe4a365c15e337b410330283868876249b5909e5da9bcb8efd815efa95b
7
+ data.tar.gz: e6cab1599d4edcf9b013a89139e7bd398764ca5491d3d0d076742472de1414cbe0ee77514b4439077d4209d9ce6c078ad3c935005ffe3753b0156b6362adea41
data/README.md CHANGED
@@ -25,6 +25,12 @@ $ gem install rails_api_guard
25
25
  rails generate rails_api_guard:install
26
26
  ```
27
27
 
28
+ ## Middleware
29
+ Add this to application.rb if not used generator
30
+ ```ruby
31
+ config.middleware.use RailsApiGuard::Middleware::RateLimiter
32
+ ```
33
+
28
34
  ## Configuration
29
35
  Edit `config/initializers/rails_api_guard.rb` to set request limits, expiry time, Slack alerts, and excluded endpoint patterns.
30
36
 
@@ -10,6 +10,20 @@ module RailsApiGuard
10
10
  def copy_initializer
11
11
  template "rails_api_guard_initializer.rb", "config/initializers/rails_api_guard.rb"
12
12
  end
13
+
14
+ def add_middleware
15
+ application_file = 'config/application.rb'
16
+ middleware_pattern = /config\.middleware\.use RailsApiGuard::Middleware::RateLimiter/
17
+ middleware_line = "\t\t# Added by RailsApiGuard gem to apply API rate limiting middleware\n"
18
+ middleware_line += "\t\tconfig.middleware.use RailsApiGuard::Middleware::RateLimiter\n"
19
+
20
+ if File.readlines(application_file).grep(/config\.middleware\.use RailsApiGuard::Middleware::RateLimiter/).any?
21
+ say_status :skipped, "Middleware already added to #{application_file}", :yellow
22
+ else
23
+ insert_into_file application_file, "\n\n#{middleware_line}", after: "class Application < Rails::Application"
24
+ say_status :added, "Middleware added to #{application_file}", :green
25
+ end
26
+ end
13
27
  end
14
28
  end
15
29
  end
@@ -1,3 +1,3 @@
1
1
  module RailsApiGuard
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_api_guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sugat dhole
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-29 00:00:00.000000000 Z
11
+ date: 2025-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails