Class: SolidLoop::Middlewares::ResponseParsing

Inherits:
Object
  • Object
show all
Defined in:
app/services/solid_loop/middlewares/response_parsing.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ResponseParsing

Returns a new instance of ResponseParsing.



6
7
8
# File 'app/services/solid_loop/middlewares/response_parsing.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'app/services/solid_loop/middlewares/response_parsing.rb', line 10

def call(env)
  # We always call the inner app first (network). ResponseParsing acts on the way back (Upstream).
  @app.call(env)

  if env.response&.success?
    process_result(env)
  elsif env.response
    handle_error(env)
  end
  # Exceptions are left to ErrorHandling middleware
end