rails-rapido 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rapido/api_controller.rb +10 -0
- data/lib/rapido/controller.rb +8 -0
- data/lib/rapido/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: ccf726284964572386ae84aba1d867157c1b91133717d6d236d0a9649124643d
|
4
|
+
data.tar.gz: e8ea92e83433412fe2b5ef62f306e23faa2ccc3b3bc62c26ffeb28022447e778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70a0e264fecd2e4e0dfcf554b75f1e5b3c2e3391d99bbfa6a78e7fd015aa41150a923ad58461c968b97781e001a8f9e6bd3609d40be79f8bd3106005dc24e3b2
|
7
|
+
data.tar.gz: 91ea1c8d258c14017b4e88fe4933133f714dd2460d1bf6cefed0190b9210e04eaa3ca8e5ddeb54051cf6af9c5cffdb522c7c990e97590a1d62378c86184b7150
|
@@ -19,6 +19,8 @@ module Rapido
|
|
19
19
|
|
20
20
|
before_action :permit_only_allowed_actions
|
21
21
|
|
22
|
+
before_action :permit_only_allowed_formats
|
23
|
+
|
22
24
|
before_action :permit_only_if
|
23
25
|
end
|
24
26
|
|
@@ -157,6 +159,14 @@ module Rapido
|
|
157
159
|
head :unauthorized unless allowed_actions.include?(params[:action].to_sym)
|
158
160
|
end
|
159
161
|
|
162
|
+
def permit_only_allowed_formats
|
163
|
+
f = params[:format]&.to_sym
|
164
|
+
unless (!f || f == :json) || (allowed_formats && allowed_formats.include?(f))
|
165
|
+
binding.pry
|
166
|
+
head :not_found
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
160
170
|
def permit_only_if
|
161
171
|
if(allow_if)
|
162
172
|
unless (allow_if.is_a?(Symbol) ? send(allow_if) : instance_eval(&allow_if))
|
data/lib/rapido/controller.rb
CHANGED
@@ -28,6 +28,10 @@ module Rapido
|
|
28
28
|
@allowed_actions = ary
|
29
29
|
end
|
30
30
|
|
31
|
+
def allowed_formats(*ary)
|
32
|
+
@allowed_formats = ary
|
33
|
+
end
|
34
|
+
|
31
35
|
def allow_if(str = nil, &block)
|
32
36
|
@allow_if = str || block
|
33
37
|
end
|
@@ -105,6 +109,10 @@ module Rapido
|
|
105
109
|
setting(:allowed_actions)
|
106
110
|
end
|
107
111
|
|
112
|
+
def allowed_formats
|
113
|
+
setting(:allowed_formats)
|
114
|
+
end
|
115
|
+
|
108
116
|
def allow_if
|
109
117
|
setting(:allow_if)
|
110
118
|
end
|
data/lib/rapido/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-rapido
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Kirst
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|