Class: Rack::DevMark::Middleware
- Inherits:
-
Object
- Object
- Rack::DevMark::Middleware
- Includes:
- Utils, Utils
- Defined in:
- lib/rack/dev-mark/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, theme = :github_fork_ribbon) ⇒ Middleware
constructor
A new instance of Middleware.
Methods included from Utils
Constructor Details
#initialize(app, theme = :github_fork_ribbon) ⇒ Middleware
Returns a new instance of Middleware.
7 8 9 10 11 |
# File 'lib/rack/dev-mark/middleware.rb', line 7 def initialize(app, theme = :github_fork_ribbon) @app = app @title = Rack::DevMark::Title.new @theme = theme.is_a?(Symbol) ? Rack::DevMark::Theme.const_get(camelize(theme.to_s)).new : theme end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rack/dev-mark/middleware.rb', line 13 def call(env) status, headers, response = @app.call(env) headers = HeaderHash.new(headers) if headers['Content-Type'].to_s =~ %r{^text/html;}i begin response = insert_dev_marks(response) rescue Rack::DevMark::Exception => e $stderr.write "Failed to insert dev marks: #{e.message}\n" end end [status, headers, response] end |