module Insights::API::Common::OptionRedirectEnhancements

Public Instance Methods

serve(req) click to toggle source
# 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