Class: OpallaMiddleware
- Inherits:
-
Object
- Object
- OpallaMiddleware
- Defined in:
- lib/opalla/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ OpallaMiddleware
constructor
A new instance of OpallaMiddleware.
- #js_routes ⇒ Object
Constructor Details
#initialize(app) ⇒ OpallaMiddleware
Returns a new instance of OpallaMiddleware.
2 3 4 |
# File 'lib/opalla/middleware.rb', line 2 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/opalla/middleware.rb', line 6 def call(env) s, h, r = @app.call(env) return [s, h, r] unless h['Content-Type'] =~ %r{text/html} html = r.body.gsub("<body>", "<body>#{js_routes}") [s, h, [html]] end |