17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/web_console/middleware.rb', line 17
def call(env)
app_exception = catch :app_exception do
request = create_regular_or_whiny_request(env)
return call_app(env) unless request.from_whitelisted_ip?
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, , body = call_app(env)
if session = Session.from(Thread.current) and acceptable_content_type?()
response = Response.new(body, status, )
template = Template.new(env, session)
response.["X-Web-Console-Session-Id"] = session.id
response.["X-Web-Console-Mount-Point"] = mount_point
response.write(template.render('index'))
response.finish
else
[ status, , body ]
end
end
rescue => e
WebConsole.logger.error("\n#{e.class}: #{e}\n\tfrom #{e.backtrace.join("\n\tfrom ")}")
raise e
ensure
Thread.current[:__web_console_exception] = nil
Thread.current[:__web_console_binding] = nil
raise app_exception if Exception === app_exception
end
|