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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c56fe3e09566c9c52b9bba52b1532971003ee171
4
- data.tar.gz: 8dd727332e2d8f642b69b1c2bc9b775253bb5295
3
+ metadata.gz: cc56c024ff64fe6859c1cfdc6fe54604a71fa806
4
+ data.tar.gz: f8679093fe49bd22661e8a086ebc0c33a0845b57
5
5
  SHA512:
6
- metadata.gz: 75299b0aa4540923f2bc275b44a2a0fedee0252ca3ff3be2d25ac9f89979125626bf73d6a21483b9d42a5c6a790d9fe3f642a87fd621166a56a3996ae149b353
7
- data.tar.gz: 1cfff39ddebd9aeb968eb7dc9220f7da03984fab27b0e94f159eacb9f170de6f4ac9c72ee734bce30ef1dc5f4cd8eccf47498c5ef61a82f2a761c5a1515ea8a6
6
+ metadata.gz: 12ea74db6fa721e5992470457581a8b26e3545ebeb82c1ccc36454c0644736a013159615755c88584e3474caac627c5156d329dc3b06e54a91f60629f9000b4b
7
+ data.tar.gz: 8180e6b31f57aa6c44f268c7fa311d425eeb34c88aba98509ddc16ba3b151fdfb9469903386911f293a3b8df93113fb918c378ddaffbf0de0884dcfb249e07e3
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Hanami::Router
2
2
  Rack compatible HTTP router for Ruby
3
3
 
4
+ ## v0.6.1 - 2016-01-27
5
+ ### Fixed
6
+ - [Luca Guidi] Fix body parsers for non Hash requests
7
+
4
8
  ## v0.6.0 - 2016-01-22
5
9
  ### Changed
6
10
  - [Luca Guidi] Renamed the project
@@ -1,6 +1,6 @@
1
1
  module Hanami
2
2
  class Router
3
3
  # @since 0.1.0
4
- VERSION = '0.6.0'.freeze
4
+ VERSION = '0.6.1'.freeze
5
5
  end
6
6
  end
@@ -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
- @parsers[
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.0
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-22 00:00:00.000000000 Z
13
+ date: 2016-01-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: http_router