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