Module: Insights::API::Common::OptionRedirectEnhancements

Defined in:
lib/insights/api/common/option_redirect_enhancements.rb

Instance Method Summary collapse

Instance Method Details

#serve(req) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/insights/api/common/option_redirect_enhancements.rb', line 5

def serve(req)
  uri = URI.parse(path(req.path_parameters, req))

  req.commit_flash

  body = %(<html><body>You are being <a href="#{ERB::Util.unwrapped_html_escape(uri.to_s)}">redirected</a>.</body></html>)

  headers = {
    "Location" => uri.to_s,
    "Content-Type" => "text/html",
    "Content-Length" => body.length.to_s
  }

  [ status, headers, [body] ]
end