twirp 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/twirp/encoding.rb +1 -1
- data/lib/twirp/error.rb +1 -1
- data/lib/twirp/version.rb +1 -1
- data/test/service_test.rb +9 -0
- data/twirp.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8558dba268ebf307651176d197204d1b803ec9429666e18f9831e597bdbb22f7
|
4
|
+
data.tar.gz: 8d2cde0d2dbaafa71ea9b2890ca459f010781f3b56c60976b2a41b5fbb69f931
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e64ccaf9a5f9005ff31c97fff51229b542492b9b6951b882836345828864173cc0f1b6f3b6831ef79f064e807438ed358f21a9cc1cc26d0c5516f095a69d91a0
|
7
|
+
data.tar.gz: 971687bef1e682359ac6a9bbfec2fdf1d4a4b44bd9a39b1732230de7aa592c4f12fc0d32001cd79cb874963f133dff832c3ebff8bf5bf32a5e0fa6d1b05e71c2
|
data/lib/twirp/encoding.rb
CHANGED
@@ -31,7 +31,7 @@ module Twirp
|
|
31
31
|
|
32
32
|
def encode(msg_obj, msg_class, content_type)
|
33
33
|
case content_type
|
34
|
-
when JSON then msg_class.encode_json(msg_obj)
|
34
|
+
when JSON then msg_class.encode_json(msg_obj, emit_defaults: true)
|
35
35
|
when PROTO then msg_class.encode(msg_obj)
|
36
36
|
else raise ArgumentError.new("Invalid content_type")
|
37
37
|
end
|
data/lib/twirp/error.rb
CHANGED
@@ -25,7 +25,7 @@ module Twirp
|
|
25
25
|
already_exists: 409, # Conflict
|
26
26
|
permission_denied: 403, # Forbidden
|
27
27
|
unauthenticated: 401, # Unauthorized
|
28
|
-
resource_exhausted:
|
28
|
+
resource_exhausted: 429, # Too Many Requests
|
29
29
|
failed_precondition: 412, # Precondition Failed
|
30
30
|
aborted: 409, # Conflict
|
31
31
|
out_of_range: 400, # Bad Request
|
data/lib/twirp/version.rb
CHANGED
data/test/service_test.rb
CHANGED
@@ -64,6 +64,15 @@ class ServiceTest < Minitest::Test
|
|
64
64
|
assert_equal({"inches" => 10, "color" => "white"}, JSON.parse(body[0]))
|
65
65
|
end
|
66
66
|
|
67
|
+
def test_successful_json_request_emit_defaults
|
68
|
+
rack_env = json_req "/example.Haberdasher/MakeHat", inches: 0 # default int value
|
69
|
+
status, headers, body = haberdasher_service.call(rack_env)
|
70
|
+
|
71
|
+
assert_equal 200, status
|
72
|
+
assert_equal 'application/json', headers['Content-Type']
|
73
|
+
assert_equal({"inches" => 0, "color" => "white"}, JSON.parse(body[0]))
|
74
|
+
end
|
75
|
+
|
67
76
|
def test_successful_proto_request
|
68
77
|
rack_env = proto_req "/example.Haberdasher/MakeHat", Example::Size.new(inches: 10)
|
69
78
|
status, headers, body = haberdasher_service.call(rack_env)
|
data/twirp.gemspec
CHANGED
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1'
|
26
26
|
spec.add_development_dependency 'minitest', '>= 5'
|
27
27
|
spec.add_development_dependency 'rake'
|
28
|
-
spec.add_development_dependency 'rack', '>= 2.
|
28
|
+
spec.add_development_dependency 'rack', '>= 2.2.3'
|
29
29
|
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.6.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: 2020-
|
12
|
+
date: 2020-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-protobuf
|
@@ -93,14 +93,14 @@ dependencies:
|
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.
|
96
|
+
version: 2.2.3
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.
|
103
|
+
version: 2.2.3
|
104
104
|
description: Twirp is a simple RPC framework with protobuf service definitions. The
|
105
105
|
Twirp gem provides native support for Ruby.
|
106
106
|
email:
|