The :server_sent_events plugin provides a DSL for handling requests which stream messages using the Server Sent Events standard.
require "httpx"
http = HTTPX.plugin(:server_sent_events)
response = http.get("https://example.com/sse", event_stream: true)
response.each_message do |message|
puts "received #{message.id}, " \
"event: #{message.event}, " \
"data: #{message.data}"
end
It’ll transparently support reconnection from the last processed message if you use the Retries plugin.
Next: Tracing