class Namira::Middleware::Responder
Builds the {Namira::Response} from the backend responses
Public Class Methods
new(app)
click to toggle source
# File lib/namira/middleware/responder.rb, line 6 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
Called by the middleware runner.
@param env [Namira::Env] The request environment
# File lib/namira/middleware/responder.rb, line 14 def call(env) env.response = handle_response(env) @app.call(env) end
Private Instance Methods
handle_response(env)
click to toggle source
# File lib/namira/middleware/responder.rb, line 21 def handle_response(env) final = Namira::Response.new( env.method, env.uri, env.redirect_count, env.response ) if (200...300).cover?(env.response.status) final else raise Errors::HTTPError.create(final) end end