aris 1.3.0 → 1.4.2
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/lib/aris/adapters/base.rb +1 -1
- data/lib/aris/adapters/mock/adapter.rb +20 -2
- data/lib/aris/adapters/rack/adapter.rb +121 -80
- data/lib/aris/config.rb +53 -0
- data/lib/aris/core.rb +4 -744
- data/lib/aris/plugins/form_parser.rb +9 -6
- data/lib/aris/router.rb +722 -0
- data/lib/aris/version.rb +1 -1
- data/lib/aris.rb +2 -0
- metadata +3 -1
|
@@ -12,10 +12,9 @@ module Aris
|
|
|
12
12
|
@config = config
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def call(request, response)
|
|
15
|
+
def self.call(request, response)
|
|
16
16
|
return nil unless PARSEABLE_METHODS.include?(request.method)
|
|
17
17
|
|
|
18
|
-
# Check content-type - access from env, not headers
|
|
19
18
|
content_type = request.env['CONTENT_TYPE']
|
|
20
19
|
return nil unless content_type&.include?('application/x-www-form-urlencoded')
|
|
21
20
|
|
|
@@ -23,11 +22,14 @@ def call(request, response)
|
|
|
23
22
|
return nil if raw_body.nil? || raw_body.empty?
|
|
24
23
|
|
|
25
24
|
begin
|
|
26
|
-
# Parse form data
|
|
27
25
|
data = ::Rack::Utils.parse_nested_query(raw_body)
|
|
26
|
+
request.instance_variable_set(:@parsed_form_data, data)
|
|
27
|
+
|
|
28
|
+
# Add clean accessor method
|
|
29
|
+
request.define_singleton_method(:form_params) do
|
|
30
|
+
@parsed_form_data || {}
|
|
31
|
+
end
|
|
28
32
|
|
|
29
|
-
# Attach parsed data to request
|
|
30
|
-
request.instance_variable_set(:@form_data, data)
|
|
31
33
|
rescue => e
|
|
32
34
|
response.status = 400
|
|
33
35
|
response.headers['content-type'] = 'text/plain'
|
|
@@ -35,7 +37,7 @@ def call(request, response)
|
|
|
35
37
|
return response
|
|
36
38
|
end
|
|
37
39
|
|
|
38
|
-
nil
|
|
40
|
+
nil
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
def self.build(**config)
|
|
@@ -44,3 +46,4 @@ end
|
|
|
44
46
|
end
|
|
45
47
|
end
|
|
46
48
|
end
|
|
49
|
+
Aris.register_plugin(:form_parser, plugin_class: Aris::Plugins::FormParser)
|