twirp-on-rails 1.0.1.pre → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.md +20 -1
- data/lib/twirp/rails/dispatcher.rb +7 -1
- data/lib/twirp/rails/rack/conditional_post.rb +2 -2
- data/lib/twirp/rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f09ec24234c61ab85dc6ab6e03768c16e4fa7110fe5e5771240ca94633996eb
|
4
|
+
data.tar.gz: 569db17177ad607e4de0a9f94cf380857c48e408f5e7937ed951bd549d5a0431
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 542712540c037f4be6ac5f322f45f72a44f55705eb813f941769317afcb17ce1853089524cdf725c61bad411fc73a8ae8be7428a8b3846df6ae9604581d5f90e
|
7
|
+
data.tar.gz: be401e0761378d95a08bc4d493582450cf5e979e288f578d63c25dd00a69bcc7033b16f77fb31bf0100c2dc1c5a7007fe1c69a8140410b0b4ee5f2238ecfd499
|
data/.standard.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -86,7 +86,26 @@ end
|
|
86
86
|
|
87
87
|
Each handler method should return the appropriate Protobuf, or a `Twirp::Error`.
|
88
88
|
|
89
|
-
|
89
|
+
#### Packages and Namespacing
|
90
|
+
|
91
|
+
Handlers can live in directories that reflect the service's package. For example, `haberdasher.proto` defines:
|
92
|
+
|
93
|
+
```protobuf
|
94
|
+
package twirp.example.haberdasher;
|
95
|
+
```
|
96
|
+
|
97
|
+
You can use the full path, or because many projects have only one namespace, we also let you skip the namespace for simplicity:
|
98
|
+
|
99
|
+
We look for the handler in either location:
|
100
|
+
|
101
|
+
`app/handlers/twirp/example/haberdasher/haberdasher_service_handler.rb` defines `Twirp::Example::Haberdasher::HaberdasherServiceHandler`
|
102
|
+
|
103
|
+
or
|
104
|
+
|
105
|
+
`app/handlers/haberdasher_service_handler.rb` defines `HaberdasherServiceHandler`
|
106
|
+
|
107
|
+
|
108
|
+
TODO: Give more examples of handlers
|
90
109
|
|
91
110
|
### Familiar Callbacks
|
92
111
|
|
@@ -4,7 +4,13 @@ module Twirp
|
|
4
4
|
module Rails
|
5
5
|
class Dispatcher
|
6
6
|
def initialize(service_class)
|
7
|
-
|
7
|
+
# Check for a handler in the service's namespace, or in the root namespace
|
8
|
+
# e.g. Twirp::Example::Cobbler::CobblerHandler or ::CobblerHandler
|
9
|
+
@service_handler = if Object.const_defined?("#{service_class.module_parent}::#{service_class.service_name}Handler")
|
10
|
+
"#{service_class.module_parent}::#{service_class.service_name}Handler".constantize
|
11
|
+
else
|
12
|
+
"#{service_class.service_name}Handler".constantize
|
13
|
+
end
|
8
14
|
end
|
9
15
|
|
10
16
|
def respond_to_missing?(method, *)
|
@@ -32,7 +32,7 @@ module Twirp
|
|
32
32
|
when "POST"
|
33
33
|
status, headers, body = response = @app.call(env)
|
34
34
|
# Rack 3 settles on only allowing lowercase headers
|
35
|
-
if Rack.release < "3.0"
|
35
|
+
if ::Rack.release < "3.0"
|
36
36
|
headers = ::Rack::Utils::HeaderHash[headers]
|
37
37
|
end
|
38
38
|
|
@@ -40,7 +40,7 @@ module Twirp
|
|
40
40
|
response[0] = 304
|
41
41
|
headers.delete(::Rack::CONTENT_TYPE)
|
42
42
|
headers.delete(::Rack::CONTENT_LENGTH)
|
43
|
-
response[2] = Rack::BodyProxy.new([]) do
|
43
|
+
response[2] = ::Rack::BodyProxy.new([]) do
|
44
44
|
body.close if body.respond_to?(:close)
|
45
45
|
end
|
46
46
|
end
|
data/lib/twirp/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twirp-on-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Morrison
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
rubygems_version: 3.5.
|
91
|
+
rubygems_version: 3.5.16
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: Use Twirp RPC with Rails
|