Sha256: 10094e8f929c1db07956ea6c7ed1e618755baf1d3ff176bd253a641ccd1d96a6
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 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 handle_request end def handle_request begin if @response_handler @base.filter :before @body = catch(:halt) { @base.eventsource &@response_handler.bind(@base) } 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 else raise NotImplementedError end 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 end def respond Angelo.log @connection, @request, nil, :ok @request.respond 200, headers, nil end end end end
Version data entries
4 entries across 4 versions & 1 rubygems