Class: CopyTunerClient::CopyrayMiddleware
- Inherits:
-
Object
- Object
- CopyTunerClient::CopyrayMiddleware
- Defined in:
- lib/copy_tuner_client/copyray_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ CopyrayMiddleware
constructor
A new instance of CopyrayMiddleware.
Constructor Details
#initialize(app) ⇒ CopyrayMiddleware
Returns a new instance of CopyrayMiddleware.
5 6 7 |
# File 'lib/copy_tuner_client/copyray_middleware.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/copy_tuner_client/copyray_middleware.rb', line 9 def call(env) CopyTunerClient::TranslationLog.clear status, headers, response = @app.call(env) if html_headers?(status, headers) && body = response_body(response) body = append_css(body) body = append_js(body) body = append_translation_logs(body) body = (body) content_length = body.bytesize.to_s if ActionDispatch::Response === response response.body = [body] response.headers['Content-Length'] = content_length response.to_a else headers['Content-Length'] = content_length [status, headers, [body]] end else [status, headers, response] end end |