protocol-rack 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/rack/adapter/rack2.rb +5 -0
- data/lib/protocol/rack/version.rb +1 -1
- data/readme.md +30 -26
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbf78ac425bc2df269ede6fc0f60d0d674f11d0e6d3fe5dc07f8c766d534bedb
|
|
4
|
+
data.tar.gz: e348d48975f98d10401e7198a7a0317483c5b2b42641a78e46e771623c804a8b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f3d717f59f06f4348fc44eba9b650cd8e99ca29ce731f5b2265e835fb95e71e1abaee47a65689903e6de48c23d1bace99c145405ad5a70de7054e2399ed202ce
|
|
7
|
+
data.tar.gz: b3fa66486f434892b3d076457d3a762fbbe1d76923c46c91e18466b00415767bded9625d13dd52cb88899b0d978915c9e3fb5c5926168ace1b1d4074d570e24e
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -116,6 +116,11 @@ module Protocol
|
|
|
116
116
|
|
|
117
117
|
body&.close if body.respond_to?(:close)
|
|
118
118
|
|
|
119
|
+
# Rack 2 does not include `rack.response_finished` in the specification. However, if the application has set it, we will call the callbacks here as it would be extremely surprising to not do so.
|
|
120
|
+
env&.[](RACK_RESPONSE_FINISHED)&.each do |callback|
|
|
121
|
+
callback.call(env, status, headers, exception)
|
|
122
|
+
end
|
|
123
|
+
|
|
119
124
|
return failure_response(exception)
|
|
120
125
|
end
|
|
121
126
|
|
data/readme.md
CHANGED
|
@@ -18,26 +18,26 @@ Please see the [project documentation](https://socketry.github.io/protocol-rack/
|
|
|
18
18
|
Given a rack application, you can adapt it for use on `async-http`:
|
|
19
19
|
|
|
20
20
|
``` ruby
|
|
21
|
-
require
|
|
22
|
-
require
|
|
23
|
-
require
|
|
24
|
-
require
|
|
25
|
-
require
|
|
21
|
+
require "async"
|
|
22
|
+
require "async/http/server"
|
|
23
|
+
require "async/http/client"
|
|
24
|
+
require "async/http/endpoint"
|
|
25
|
+
require "protocol/rack/adapter"
|
|
26
26
|
|
|
27
27
|
app = proc{|env| [200, {}, ["Hello World"]]}
|
|
28
28
|
middleware = Protocol::Rack::Adapter.new(app)
|
|
29
29
|
|
|
30
30
|
Async do
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
endpoint = Async::HTTP::Endpoint.parse("http://localhost:9292")
|
|
32
|
+
|
|
33
|
+
server_task = Async(transient: true) do
|
|
34
|
+
server = Async::HTTP::Server.new(middleware, endpoint)
|
|
35
|
+
server.run
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
client = Async::HTTP::Client.new(endpoint)
|
|
39
|
+
puts client.get("/").read
|
|
40
|
+
# "Hello World"
|
|
41
41
|
end
|
|
42
42
|
```
|
|
43
43
|
|
|
@@ -46,27 +46,31 @@ end
|
|
|
46
46
|
While not tested, in theory any Rack compatible server can host `Protocol::HTTP` compatible middlewares.
|
|
47
47
|
|
|
48
48
|
``` ruby
|
|
49
|
-
require
|
|
50
|
-
require
|
|
49
|
+
require "protocol/http/middleware"
|
|
50
|
+
require "protocol/rack"
|
|
51
51
|
|
|
52
52
|
# Your native application:
|
|
53
53
|
middleware = Protocol::HTTP::Middleware::HelloWorld
|
|
54
54
|
|
|
55
|
-
run
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
run do |env|
|
|
56
|
+
# Convert the rack request to a compatible rich request object:
|
|
57
|
+
request = Protocol::Rack::Request[env]
|
|
58
|
+
|
|
59
|
+
# Call your application
|
|
60
|
+
response = middleware.call(request)
|
|
61
|
+
|
|
62
|
+
Protocol::Rack::Adapter.make_response(env, response)
|
|
63
|
+
end
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
## Releases
|
|
67
67
|
|
|
68
68
|
Please see the [project releases](https://socketry.github.io/protocol-rack/releases/index) for all releases.
|
|
69
69
|
|
|
70
|
+
### v0.17.0
|
|
71
|
+
|
|
72
|
+
- Support `rack.response_finished` in Rack 2 if it's present in the environment.
|
|
73
|
+
|
|
70
74
|
### v0.16.0
|
|
71
75
|
|
|
72
76
|
- Hijacked IO is no longer duped, as it's not retained by the original connection, and `SSLSocket` does not support duping.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: protocol-rack
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.17.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
125
125
|
- !ruby/object:Gem::Version
|
|
126
126
|
version: '0'
|
|
127
127
|
requirements: []
|
|
128
|
-
rubygems_version: 3.6.
|
|
128
|
+
rubygems_version: 3.6.9
|
|
129
129
|
specification_version: 4
|
|
130
130
|
summary: An implementation of the Rack protocol/specification.
|
|
131
131
|
test_files: []
|
metadata.gz.sig
CHANGED
|
Binary file
|