twirp 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/twirp/service.rb +6 -2
- data/lib/twirp/version.rb +1 -1
- data/test/service_test.rb +4 -2
- data/twirp.gemspec +3 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83302ec929694b2ac96f016518ad5585de1fa65e
|
4
|
+
data.tar.gz: c79097cde99163118952b003b1402332f83b8c7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba357830275b3b4af11bc6f7319118a17a4405c338592ccb26293a0fed95622612b7f6d167214254eb6b0c05664d91f2ca5c847aeceb171e7c3dd0395f73d7ec
|
7
|
+
data.tar.gz: '05581b8cb43081e0e0103f6e3c50af6dfa0280b67355307418d287086e0c109e335bd0708f84eed4561eca7c288f1aa98884e71524a797ad07fe081a737efa3f'
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[Twirp is a protocol](https://twitchtv.github.io/twirp/docs/spec_v5.html) for routing and serialization of services defined in a [.proto file](https://developers.google.com/protocol-buffers/docs/proto3), allowing easy implementation of RPC services with auto-generated clients in different languages.
|
4
4
|
|
5
|
-
The [
|
5
|
+
The [canonical implementation](https://github.com/twitchtv/twirp) is in Golang. The Twirp-Ruby project in this repository is the Ruby implementation.
|
6
6
|
|
7
7
|
|
8
8
|
## Install
|
@@ -13,3 +13,8 @@ Add `gem "twirp"` to your Gemfile, or install with `gem install twirp`.
|
|
13
13
|
## Documentation
|
14
14
|
|
15
15
|
[Go to the Wiki](https://github.com/twitchtv/twirp-ruby/wiki).
|
16
|
+
|
17
|
+
|
18
|
+
## Contributing
|
19
|
+
|
20
|
+
[Go to the CONTRIBUTING file](CONTRIBUTING.md).
|
data/lib/twirp/service.rb
CHANGED
@@ -127,8 +127,12 @@ module Twirp
|
|
127
127
|
input = nil
|
128
128
|
begin
|
129
129
|
input = Encoding.decode(rack_request.body.read, env[:input_class], content_type)
|
130
|
-
rescue
|
131
|
-
|
130
|
+
rescue => e
|
131
|
+
error_msg = "Invalid request body for rpc method #{method_name.inspect} with Content-Type=#{content_type}"
|
132
|
+
if e.is_a?(Google::Protobuf::ParseError)
|
133
|
+
error_msg += ": #{e.message.strip}"
|
134
|
+
end
|
135
|
+
return bad_route_error(error_msg, rack_request)
|
132
136
|
end
|
133
137
|
|
134
138
|
env[:input] = input
|
data/lib/twirp/version.rb
CHANGED
data/test/service_test.rb
CHANGED
@@ -140,7 +140,8 @@ class ServiceTest < Minitest::Test
|
|
140
140
|
assert_equal 'application/json', headers['Content-Type']
|
141
141
|
assert_equal({
|
142
142
|
"code" => 'bad_route',
|
143
|
-
"msg" => 'Invalid request body for rpc method "MakeHat" with Content-Type=application/json'
|
143
|
+
"msg" => 'Invalid request body for rpc method "MakeHat" with Content-Type=application/json: ' +
|
144
|
+
"Error occurred during parsing: Parse error at 'bad json'",
|
144
145
|
"meta" => {"twirp_invalid_route" => "POST /example.Haberdasher/MakeHat"},
|
145
146
|
}, JSON.parse(body[0]))
|
146
147
|
end
|
@@ -154,7 +155,8 @@ class ServiceTest < Minitest::Test
|
|
154
155
|
assert_equal 'application/json', headers['Content-Type']
|
155
156
|
assert_equal({
|
156
157
|
"code" => 'bad_route',
|
157
|
-
"msg" => 'Invalid request body for rpc method "MakeHat" with Content-Type=application/protobuf'
|
158
|
+
"msg" => 'Invalid request body for rpc method "MakeHat" with Content-Type=application/protobuf: ' +
|
159
|
+
'Error occurred during parsing: Unexpected EOF inside skipped data',
|
158
160
|
"meta" => {"twirp_invalid_route" => "POST /example.Haberdasher/MakeHat"},
|
159
161
|
}, JSON.parse(body[0]))
|
160
162
|
end
|
data/twirp.gemspec
CHANGED
@@ -21,5 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.required_ruby_version = '>= 1.9'
|
22
22
|
spec.add_runtime_dependency 'google-protobuf', '~> 3.0', '>= 3.0.0'
|
23
23
|
spec.add_runtime_dependency 'faraday', '~> 0' # for clients
|
24
|
+
|
24
25
|
spec.add_development_dependency 'bundler', '~> 1'
|
26
|
+
spec.add_development_dependency 'minitest', '>= 5'
|
27
|
+
spec.add_development_dependency 'rake'
|
25
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twirp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyrus A. Forbes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-protobuf
|
@@ -59,6 +59,34 @@ dependencies:
|
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: minitest
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5'
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: rake
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
62
90
|
description: Twirp is a simple RPC framework with protobuf service definitions. The
|
63
91
|
Twirp gem provides native support for Ruby.
|
64
92
|
email:
|