hanami-router 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/hanami/router/version.rb +1 -1
- data/lib/hanami/routing/parsers.rb +16 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc56c024ff64fe6859c1cfdc6fe54604a71fa806
|
4
|
+
data.tar.gz: f8679093fe49bd22661e8a086ebc0c33a0845b57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12ea74db6fa721e5992470457581a8b26e3545ebeb82c1ccc36454c0644736a013159615755c88584e3474caac627c5156d329dc3b06e54a91f60629f9000b4b
|
7
|
+
data.tar.gz: 8180e6b31f57aa6c44f268c7fa311d425eeb34c88aba98509ddc16ba3b151fdfb9469903386911f293a3b8df93113fb918c378ddaffbf0de0884dcfb249e07e3
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,7 @@ module Hanami
|
|
8
8
|
|
9
9
|
RACK_INPUT = 'rack.input'.freeze
|
10
10
|
ROUTER_PARAMS = 'router.params'.freeze
|
11
|
+
FALLBACK_KEY = '_'.freeze
|
11
12
|
|
12
13
|
def initialize(parsers)
|
13
14
|
@parsers = prepare(parsers)
|
@@ -44,18 +45,29 @@ module Hanami
|
|
44
45
|
return env if body.empty?
|
45
46
|
|
46
47
|
env[RACK_INPUT].rewind # somebody might try to read this stream
|
47
|
-
env[ROUTER_PARAMS] ||= {} # prepare params
|
48
48
|
|
49
|
+
env[ROUTER_PARAMS] ||= {} # prepare params
|
49
50
|
env[ROUTER_PARAMS].merge!(
|
50
|
-
|
51
|
-
media_type(env)
|
52
|
-
].parse(body)
|
51
|
+
_parse(env, body)
|
53
52
|
)
|
54
53
|
|
55
54
|
env
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
58
|
+
def _parse(env, body)
|
59
|
+
result = @parsers[
|
60
|
+
media_type(env)
|
61
|
+
].parse(body)
|
62
|
+
|
63
|
+
case result
|
64
|
+
when Hash
|
65
|
+
result
|
66
|
+
else
|
67
|
+
{FALLBACK_KEY => result}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
59
71
|
def media_type(env)
|
60
72
|
if ct = content_type(env)
|
61
73
|
ct.split(MEDIA_TYPE_MATCHER, 2).first.downcase
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-01-
|
13
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http_router
|