Class: Plumbo::Middleware::Injection
- Inherits:
-
Object
- Object
- Plumbo::Middleware::Injection
- Defined in:
- lib/plumbo/middleware.rb
Overview
Adds the panel to a single response: an X-Plumbo-Files header on anything with files, plus the injected panel markup for full HTML pages. Holds the response triple and files as instance state.
Instance Method Summary collapse
-
#apply ⇒ Object
The final Rack triple, with the header and (for full HTML) the panel.
-
#initialize(triple, files) ⇒ Injection
constructor
A new instance of Injection.
Constructor Details
#initialize(triple, files) ⇒ Injection
Returns a new instance of Injection.
52 53 54 55 |
# File 'lib/plumbo/middleware.rb', line 52 def initialize(triple, files) @status, @headers, @response = triple @files = files end |
Instance Method Details
#apply ⇒ Object
The final Rack triple, with the header and (for full HTML) the panel.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/plumbo/middleware.rb', line 58 def apply passthrough = [@status, @headers, @response] return passthrough if @files.empty? @headers[HEADER] = header_value return passthrough unless html? body = rewrite @headers["Content-Length"] = body.bytesize.to_s [@status, @headers, [body]] end |