Class: Insight::RedirectInterceptor
- Inherits:
-
Object
- Object
- Insight::RedirectInterceptor
- Includes:
- Render
- Defined in:
- lib/insight/redirect_interceptor.rb
Instance Method Summary (collapse)
- - (Object) call(env)
-
- (RedirectInterceptor) initialize(app)
constructor
A new instance of RedirectInterceptor.
- - (Object) intercept_redirect
Methods included from Render
#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params
Methods included from Logging
Constructor Details
- (RedirectInterceptor) initialize(app)
A new instance of RedirectInterceptor
5 6 7 |
# File 'lib/insight/redirect_interceptor.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
- (Object) call(env)
9 10 11 12 13 14 15 16 |
# File 'lib/insight/redirect_interceptor.rb', line 9 def call(env) status, headers, body = @app.call(env) @response = Rack::Response.new(body, status, headers) if @response.redirect? && env["insight.intercept_redirects"] intercept_redirect end @response.to_a end |
- (Object) intercept_redirect
18 19 20 21 22 |
# File 'lib/insight/redirect_interceptor.rb', line 18 def intercept_redirect new_body = render_template("redirect", :redirect_to => @response.location) new_headers = { "Content-Type" => "text/html", "Content-Length" => new_body.size.to_s } @response = Rack::Response.new(new_body, 200, new_headers) end |