rack-parser 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +14 -1
- data/lib/rack/parser.rb +1 -1
- data/rack-parser.gemspec +1 -1
- metadata +14 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2bfc0d8a49d8bbfbea8feb0f9760dd7ddc4ab9a4
|
4
|
+
data.tar.gz: b2012859f92dc0317ca7d3db060ed82aececaf31
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dcbf8aad748d39e46dd18557c44184bd5500ca38d55420f5e30f16b6b8aabfbc4577ccae569658c4c269b74ed80d91d47dfc9c3b22c8926fde5c6ea88988a152
|
7
|
+
data.tar.gz: e73679c51a235e0983fdca3bbb9b2fded19ebb8d0ec62da4ae486d35340c702df403314f6bf7adaa219f36cbad1746397eba9158e8c19f299d1e3ca664552094
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ In a Sinatra or [Padrino](http://padrinorb.com) application, it would probably b
|
|
27
27
|
```ruby
|
28
28
|
# app.rb
|
29
29
|
|
30
|
-
use Rack::Parser :parsers => { 'application/json' => proc { |data| JSON.parse data },
|
30
|
+
use Rack::Parser, :parsers => { 'application/json' => proc { |data| JSON.parse data },
|
31
31
|
'application/xml' => proc { |data| XML.parse data },
|
32
32
|
%r{msgpack} => proc { |data| Msgpack.parse data }
|
33
33
|
}
|
@@ -67,6 +67,18 @@ override the default response as well.
|
|
67
67
|
|
68
68
|
If no content_type error handling response is present, it will return `400`
|
69
69
|
|
70
|
+
### Regex Matching ###
|
71
|
+
|
72
|
+
With version `0.4.0`, you can specify regex matches for the content
|
73
|
+
types that you want the `parsers` and `handlers` to match.
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
parser = proc { |data| JSON.parse data }
|
77
|
+
handler = proc { |e, type| [400, {}, 'boop'] }
|
78
|
+
use Rack::Parser, :parsers => { %r{json} => parser },
|
79
|
+
:handlers => { %r{heyyyy} => handler }
|
80
|
+
```
|
81
|
+
|
70
82
|
## Inspirations ##
|
71
83
|
|
72
84
|
This project came to being because of:
|
@@ -87,6 +99,7 @@ This project came to being because of:
|
|
87
99
|
* [Moonsik Kang](https://github.com/deepblue) - skip rack parser for content types that are not explicitly set.
|
88
100
|
* [Guillermo Iguaran](https://github.com/guilleiguaran) - Updating `multi_xml` version dependency for XML/YAML exploit
|
89
101
|
* [Doug Orleans](https://github.com/dougo) - Handle only post-body parsing errors and let upstream errors propogate downstream
|
102
|
+
* [Akshay Moghe](https://github.com/amoghe) - Make default error handler rack compliant by responding to #each
|
90
103
|
|
91
104
|
## Copyright
|
92
105
|
|
data/lib/rack/parser.rb
CHANGED
@@ -6,7 +6,7 @@ module Rack
|
|
6
6
|
FORM_HASH = 'rack.request.form_hash'.freeze
|
7
7
|
|
8
8
|
JSON_PARSER = proc { |data| JSON.parse data }
|
9
|
-
ERROR_HANDLER = proc { |err, type| [400, {}, ''] }
|
9
|
+
ERROR_HANDLER = proc { |err, type| [400, {}, ['']] }
|
10
10
|
|
11
11
|
attr_reader :parsers, :handlers, :logger
|
12
12
|
|
data/rack-parser.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rack-parser"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.5.0"
|
7
7
|
s.authors = ["Arthur Chiu"]
|
8
8
|
s.email = ["mr.arthur.chiu@gmail.com"]
|
9
9
|
s.homepage = "https://www.github.com/achiu/rack-parser"
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Arthur Chiu
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rack
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: minitest
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rack-test
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Rack Middleware for parsing post body data for json, xml and various
|
@@ -78,28 +71,28 @@ files:
|
|
78
71
|
- spec/spec_helper.rb
|
79
72
|
homepage: https://www.github.com/achiu/rack-parser
|
80
73
|
licenses: []
|
74
|
+
metadata: {}
|
81
75
|
post_install_message:
|
82
76
|
rdoc_options: []
|
83
77
|
require_paths:
|
84
78
|
- lib
|
85
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
-
none: false
|
87
80
|
requirements:
|
88
|
-
- -
|
81
|
+
- - '>='
|
89
82
|
- !ruby/object:Gem::Version
|
90
83
|
version: '0'
|
91
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
85
|
requirements:
|
94
|
-
- -
|
86
|
+
- - '>='
|
95
87
|
- !ruby/object:Gem::Version
|
96
88
|
version: '0'
|
97
89
|
requirements: []
|
98
90
|
rubyforge_project: rack-parser
|
99
|
-
rubygems_version:
|
91
|
+
rubygems_version: 2.0.3
|
100
92
|
signing_key:
|
101
|
-
specification_version:
|
93
|
+
specification_version: 4
|
102
94
|
summary: Rack Middleware for parsing post body data
|
103
95
|
test_files:
|
104
96
|
- spec/parser_spec.rb
|
105
97
|
- spec/spec_helper.rb
|
98
|
+
has_rdoc:
|