class Rack::App::Endpoint::Catcher
Constants
- EXTNAME
Public Class Methods
new(app, endpoint_properties)
click to toggle source
# File lib/rack/app/endpoint/catcher.rb, line 3 def initialize(app, endpoint_properties) @app = app @endpoint_properties = endpoint_properties end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/app/endpoint/catcher.rb, line 8 def call(env) resp = handle_rack_response do handle_response_body(env) do @app.call(env) end end return resp.finish if resp.is_a?(Rack::Response) resp end
Protected Instance Methods
handle_rack_response() { || ... }
click to toggle source
# File lib/rack/app/endpoint/catcher.rb, line 21 def handle_rack_response catch(:rack_response) { return yield }.finish end
handle_response_body(env) { || ... }
click to toggle source
# File lib/rack/app/endpoint/catcher.rb, line 25 def handle_response_body(env) body = catch(:response_body) { return yield } request_handler = env[Rack::App::Constants::ENV::HANDLER] set_response_body(request_handler, body) throw :rack_response, request_handler.response end
set_response_body(handler, response_body)
click to toggle source
# File lib/rack/app/endpoint/catcher.rb, line 34 def set_response_body(handler, response_body) extname = handler.request.env[EXTNAME] handler.response.headers.merge!(@endpoint_properties.serializer.response_headers_for(extname)) handler.response.write(@endpoint_properties.serializer.serialize(extname, response_body)) end