protocol-rack 0.18.0 → 0.19.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/context/getting-started.md +22 -0
- data/lib/protocol/rack/adapter/rack2.rb +2 -2
- data/lib/protocol/rack/adapter/rack3.rb +2 -2
- data/lib/protocol/rack/version.rb +1 -1
- data/readme.md +4 -50
- data/releases.md +4 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- 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: 5864594e5fdeb7192006dc95ccc3d448a0c9b953e331f2df4a9bacad898309d5
|
|
4
|
+
data.tar.gz: 056de84f70c904d064de318a532ea46ae1568e6882568a7c965f767696d984d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5567e929cdedd1a8bdc9595d1b25c36b918bda3fe107c8e36af47af5a9fa95f8aaa311de7454df88c3dfecc437dd45c55b3763465314225ffa1902958d03423c
|
|
7
|
+
data.tar.gz: c34f91c5a27fdccf962fe1738b6aeb23022c83e4923c7190ecede735d78cf3bb6dd5a9a6757148ee5b17e1e5750f9e2751dc90905efb42255e88ed916966016c
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/context/getting-started.md
CHANGED
|
@@ -53,3 +53,25 @@ end
|
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
The adapter automatically detects your Rack version (v2, v3, or v3.1+) and uses the appropriate implementation, ensuring compatibility without any configuration.
|
|
56
|
+
|
|
57
|
+
### Server Adapter
|
|
58
|
+
|
|
59
|
+
Any Rack compatible server can host `Protocol::HTTP` compatible middlewares.
|
|
60
|
+
|
|
61
|
+
``` ruby
|
|
62
|
+
require "protocol/http/middleware"
|
|
63
|
+
require "protocol/rack"
|
|
64
|
+
|
|
65
|
+
# Your native application:
|
|
66
|
+
middleware = Protocol::HTTP::Middleware::HelloWorld
|
|
67
|
+
|
|
68
|
+
run do |env|
|
|
69
|
+
# Convert the rack request to a compatible rich request object:
|
|
70
|
+
request = Protocol::Rack::Request[env]
|
|
71
|
+
|
|
72
|
+
# Call your application
|
|
73
|
+
response = middleware.call(request)
|
|
74
|
+
|
|
75
|
+
Protocol::Rack::Adapter.make_response(env, response)
|
|
76
|
+
end
|
|
77
|
+
```
|
|
@@ -131,10 +131,10 @@ module Protocol
|
|
|
131
131
|
meta[key] = value
|
|
132
132
|
elsif value.is_a?(String)
|
|
133
133
|
value.split("\n").each do |value|
|
|
134
|
-
headers
|
|
134
|
+
headers.add(key, value)
|
|
135
135
|
end
|
|
136
136
|
else
|
|
137
|
-
headers
|
|
137
|
+
headers.add(key, value)
|
|
138
138
|
end
|
|
139
139
|
end
|
|
140
140
|
|
data/readme.md
CHANGED
|
@@ -17,60 +17,14 @@ Please see the [project documentation](https://socketry.github.io/protocol-rack/
|
|
|
17
17
|
|
|
18
18
|
- [Request and Response Handling](https://socketry.github.io/protocol-rack/guides/request-response/index) - This guide explains how to work with requests and responses when bridging between Rack and `Protocol::HTTP`, covering advanced use cases and edge cases.
|
|
19
19
|
|
|
20
|
-
### Application Adapter
|
|
21
|
-
|
|
22
|
-
Given a rack application, you can adapt it for use on `async-http`:
|
|
23
|
-
|
|
24
|
-
``` ruby
|
|
25
|
-
require "async"
|
|
26
|
-
require "async/http/server"
|
|
27
|
-
require "async/http/client"
|
|
28
|
-
require "async/http/endpoint"
|
|
29
|
-
require "protocol/rack/adapter"
|
|
30
|
-
|
|
31
|
-
app = proc{|env| [200, {}, ["Hello World"]]}
|
|
32
|
-
middleware = Protocol::Rack::Adapter.new(app)
|
|
33
|
-
|
|
34
|
-
Async do
|
|
35
|
-
endpoint = Async::HTTP::Endpoint.parse("http://localhost:9292")
|
|
36
|
-
|
|
37
|
-
server_task = Async(transient: true) do
|
|
38
|
-
server = Async::HTTP::Server.new(middleware, endpoint)
|
|
39
|
-
server.run
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
client = Async::HTTP::Client.new(endpoint)
|
|
43
|
-
puts client.get("/").read
|
|
44
|
-
# "Hello World"
|
|
45
|
-
end
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Server Adapter
|
|
49
|
-
|
|
50
|
-
While not tested, in theory any Rack compatible server can host `Protocol::HTTP` compatible middlewares.
|
|
51
|
-
|
|
52
|
-
``` ruby
|
|
53
|
-
require "protocol/http/middleware"
|
|
54
|
-
require "protocol/rack"
|
|
55
|
-
|
|
56
|
-
# Your native application:
|
|
57
|
-
middleware = Protocol::HTTP::Middleware::HelloWorld
|
|
58
|
-
|
|
59
|
-
run do |env|
|
|
60
|
-
# Convert the rack request to a compatible rich request object:
|
|
61
|
-
request = Protocol::Rack::Request[env]
|
|
62
|
-
|
|
63
|
-
# Call your application
|
|
64
|
-
response = middleware.call(request)
|
|
65
|
-
|
|
66
|
-
Protocol::Rack::Adapter.make_response(env, response)
|
|
67
|
-
end
|
|
68
|
-
```
|
|
69
|
-
|
|
70
20
|
## Releases
|
|
71
21
|
|
|
72
22
|
Please see the [project releases](https://socketry.github.io/protocol-rack/releases/index) for all releases.
|
|
73
23
|
|
|
24
|
+
### v0.19.0
|
|
25
|
+
|
|
26
|
+
- Use `Headers#add` instead of `Headers#[]=` in Rack3 and Rack31 adapters, which is the correct interface for appending headers.
|
|
27
|
+
|
|
74
28
|
### v0.18.0
|
|
75
29
|
|
|
76
30
|
- Correctly invoke `rack.response_finished` in reverse order.
|
data/releases.md
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|