em-eventsource 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/em-eventsource.rb +9 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 461c9ac878e1f325156439b1d51c298db29fbcc9c23e769fdf0c480baeb83f57
|
4
|
+
data.tar.gz: 1b9077e69942f41ce43c304116bb7923b66cb398935e3da578b76e03176b60ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b689983d0970f0f072d1f34ea79c47948b084072ce94b014ef4da1b340cc9c6673a00a1eece3fbe2585e56425090fb7d4186275d6d2f097abafcf1bcacc1e455
|
7
|
+
data.tar.gz: 65d3b2e2f93416796ec3f958cc9d64253fd24db69c944b5f08aeb6f964efec3715330c9dbc2de3f095273d647358e304465d812c7a1e03918eaa2270c8254ae7
|
data/README.md
CHANGED
data/lib/em-eventsource.rb
CHANGED
@@ -88,7 +88,8 @@ module EventMachine
|
|
88
88
|
#
|
89
89
|
# Returns nothing
|
90
90
|
def use(*args, &block)
|
91
|
-
|
91
|
+
block = args.pop if block.nil? && block_given?
|
92
|
+
@middlewares << [args, block]
|
92
93
|
end
|
93
94
|
|
94
95
|
# Start subscription
|
@@ -179,10 +180,13 @@ module EventMachine
|
|
179
180
|
|
180
181
|
def prepare_request
|
181
182
|
conn = EM::HttpRequest.new(@url, inactivity_timeout: @inactivity_timeout)
|
182
|
-
@middlewares.each
|
183
|
-
block
|
184
|
-
|
185
|
-
|
183
|
+
@middlewares.each do |middleware, block|
|
184
|
+
if block
|
185
|
+
conn.use(*middleware, &block)
|
186
|
+
else
|
187
|
+
conn.use(*middleware)
|
188
|
+
end
|
189
|
+
end
|
186
190
|
headers = @headers.merge({'Cache-Control' => 'no-cache', 'Accept' => 'text/event-stream'})
|
187
191
|
headers.merge!({'Last-Event-Id' => @last_event_id }) if not @last_event_id.nil?
|
188
192
|
[conn, conn.get({ query: @query,
|