Class: WebConsole::Middleware
- Inherits:
- 
      Object
      
        - Object
- WebConsole::Middleware
 
- Defined in:
- lib/web_console/middleware.rb
Constant Summary collapse
- TEMPLATES_PATH =
- File.('../templates', __FILE__) 
- DEFAULT_OPTIONS =
- { update_re: %r{/repl_sessions/(?<id>.+?)\z}, binding_change_re: %r{/repl_sessions/(?<id>.+?)/trace\z} } 
- UNAVAILABLE_SESSION_MESSAGE =
- " Session %{id} is is no longer available in memory.\n\n If you happen to run on a multi-process server (like Unicorn) the process\n this request hit doesn't store %{id} in memory.\n".strip_heredoc 
- @@whiny_requests =
- true
Instance Method Summary collapse
- #call(env) ⇒ Object
- 
  
    
      #initialize(app, options = {})  ⇒ Middleware 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Middleware. 
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
| 22 23 24 25 | # File 'lib/web_console/middleware.rb', line 22 def initialize(app, = {}) @app = app = DEFAULT_OPTIONS.merge() end | 
Instance Method Details
#call(env) ⇒ Object
| 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 53 54 | # File 'lib/web_console/middleware.rb', line 27 def call(env) request = create_regular_or_whiny_request(env) return @app.call(env) unless request.from_whitelited_ip? if id = id_for_repl_session_update(request) return update_repl_session(id, request.params) elsif id = id_for_repl_session_stack_frame_change(request) return change_stack_trace(id, request.params) end status, headers, body = @app.call(env) if exception = env['web_console.exception'] session = Session.from_exception(exception) elsif binding = env['web_console.binding'] session = Session.from_binding(binding) end if session && request.acceptable_content_type? response = Rack::Response.new(body, status, headers) template = Template.new(env, session) response.write(template.render('index')) response.finish else [ status, headers, body ] end end |