Class: Scratchpad::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/scratchpad/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



3
4
5
# File 'lib/scratchpad/middleware.rb', line 3

def initialize app
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/scratchpad/middleware.rb', line 7

def call env
  scratchpad = Scratchpad::Page.new(env)
  status, headers, response = @app.call(env)
  if headers["Content-Type"] && headers["Content-Type"].include?("text/html")
    [status, headers, [response.body + scratchpad.to_html]]
  else
    [status, headers, response]
  end
end