class WebConsole::Middleware

def call(env)

Experimental RBS support (using type sampling data from the type_fusion project).

def call: (Hash env) -> Array[Integer]

This signature was generated using 1 sample from 1 application.

def call(env)
  app_exception = catch :app_exception do
    request = create_regular_or_whiny_request(env)
    return call_app(env) unless request.permitted?
    if id = id_for_repl_session_update(request)
      return update_repl_session(id, request)
    elsif id = id_for_repl_session_stack_frame_change(request)
      return change_stack_trace(id, request)
    end
    status, headers, body = call_app(env)
    if (session = Session.from(Thread.current)) && acceptable_content_type?(headers)
      headers["X-Web-Console-Session-Id"] = session.id
      headers["X-Web-Console-Mount-Point"] = mount_point
      template = Template.new(env, session)
      body, headers = Injector.new(body, headers).inject(template.render("index"))
    end
    [ status, headers, body ]
  end
rescue => e
  WebConsole.logger.error("\n#{e.class}: #{e}\n\tfrom #{e.backtrace.join("\n\tfrom ")}")
  raise e
ensure
  # Clean up the fiber locals after the session creation. Object#console
  # uses those to communicate the current binding or exception to the middleware.
  Thread.current[:__web_console_exception] = nil
  Thread.current[:__web_console_binding] = nil
  raise app_exception if Exception === app_exception
end