Sha256: e4416f9714e5c270448cf8f7a32396a7a558e99a57e54aed61e81bf5b34871e2
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
module Angelo class Responder class Eventsource < Responder def initialize _headers = nil, &block headers _headers if _headers super &block end def request= request @params = nil @request = request end def handle_request if !@response_handler raise NotImplementedError end @base.filter :before @body = catch(:halt) do @base.eventsource do |socket| @base.instance_exec(socket, &@response_handler) end end if HALT_STRUCT === @body raise RequestError.new 'unknown sse error' unless @body.body == :sse end # TODO any real reason not to run afters with SSE? # @base.filter :after respond rescue IOError => ioe warn "#{ioe.class} - #{ioe.message}" rescue RequestError => re headers SSE_HEADER handle_error re, re.type rescue => e handle_error e end def respond Angelo.log @connection, @request, nil, :ok @request.respond 200, headers, nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
angelo-0.4.1 | lib/angelo/responder/eventsource.rb |
angelo-0.4.0 | lib/angelo/responder/eventsource.rb |