Class: Rack::Livejs
- Inherits:
-
Object
- Object
- Rack::Livejs
- Defined in:
- lib/rack/livejs.rb,
lib/rack/livejs/version.rb
Constant Summary collapse
- VERSION =
"0.2.1"
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Livejs
constructor
A new instance of Livejs.
Constructor Details
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
6 7 8 |
# File 'lib/rack/livejs.rb', line 6 def app @app end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/rack/livejs.rb', line 15 def call(env) status, headers, body = @app.call(env) if headers["Content-Type"] == "text/html" new_html = inject_livejs(read_body(body)) headers["Content-Length"] = new_html.size.to_s body = [new_html] end [status, headers, body] end |