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 +4 -4
- data/README.md +6 -0
- data/lib/rails_api_guard/generators/install/install_generator.rb +14 -0
- data/lib/rails_api_guard/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93890693de684b76c7ac78ed99e9d1ca804272c7cbf14b1c8087d5070ab2fcea
|
4
|
+
data.tar.gz: f4056a7057f5d56e26143ebf7d810d2d742090a2e920c4cf29a9b289bea96924
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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-
|
11
|
+
date: 2025-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|