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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fed6d6b2ffc0dc007d343e8f9414af4c61cd7c321cb289b6d218290977feb7f
4
- data.tar.gz: d02dd7e216b58d3bbe94e5e99b4c71d689ad8de5cb7451a67a81bcd0ade5a55a
3
+ metadata.gz: 5864594e5fdeb7192006dc95ccc3d448a0c9b953e331f2df4a9bacad898309d5
4
+ data.tar.gz: 056de84f70c904d064de318a532ea46ae1568e6882568a7c965f767696d984d9
5
5
  SHA512:
6
- metadata.gz: df29bd96d8542e75e146d0eec4d7813f7e037fdd84e68bd08ac1f6a4cfca66b3ec176dd3167e31eedb3ae849b44059c23b0fe57a4aea8b4a2c3f55c90755b36f
7
- data.tar.gz: 6969ef3c4a7fb95083dd57697c5bcf0aee57ec1f9eee6f0b4233af56e4845513c21480cee2abc14daf320d5cf7c5c739b50448bc3d3c6023432292a6544d8876
6
+ metadata.gz: 5567e929cdedd1a8bdc9595d1b25c36b918bda3fe107c8e36af47af5a9fa95f8aaa311de7454df88c3dfecc437dd45c55b3763465314225ffa1902958d03423c
7
+ data.tar.gz: c34f91c5a27fdccf962fe1738b6aeb23022c83e4923c7190ecede735d78cf3bb6dd5a9a6757148ee5b17e1e5750f9e2751dc90905efb42255e88ed916966016c
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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[key] = value
134
+ headers.add(key, value)
135
135
  end
136
136
  else
137
- headers[key] = value
137
+ headers.add(key, value)
138
138
  end
139
139
  end
140
140
 
@@ -103,10 +103,10 @@ module Protocol
103
103
  meta[key] = value
104
104
  elsif value.is_a?(Array)
105
105
  value.each do |value|
106
- headers[key] = value
106
+ headers.add(key, value)
107
107
  end
108
108
  else
109
- headers[key] = value
109
+ headers.add(key, value)
110
110
  end
111
111
  end
112
112
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module Rack
8
- VERSION = "0.18.0"
8
+ VERSION = "0.19.0"
9
9
  end
10
10
  end
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
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.19.0
4
+
5
+ - Use `Headers#add` instead of `Headers#[]=` in Rack3 and Rack31 adapters, which is the correct interface for appending headers.
6
+
3
7
  ## v0.18.0
4
8
 
5
9
  - Correctly invoke `rack.response_finished` in reverse order.
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.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file