Class: Hotwire::Spark::Middleware
- Inherits:
-
Object
- Object
- Hotwire::Spark::Middleware
- Defined in:
- lib/hotwire/spark/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
2 3 4 |
# File 'lib/hotwire/spark/middleware.rb', line 2 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hotwire/spark/middleware.rb', line 6 def call(env) status, headers, response = @app.call(env) @request = ActionDispatch::Request.new(env) if interceptable_request? && html_response?(headers) html = html_from(response) html = (html) html = inject_javascript(html) headers["Content-Length"] = html.bytesize.to_s if html response = [ html ] end [ status, headers, response ] end |