Sha256: fea364c147d36fa75a516464b92c6dcc373a79b96968b808537a46cf91b62a87

Contents?: true

Size: 430 Bytes

Versions: 7

Compression:

Stored size: 430 Bytes

Contents

module Rack::App::InstanceMethods::RedirectTo 

  def redirect_to(url, params={})

    if params.empty?
      url = [url, request.env['QUERY_STRING']].join('?') unless request.env['QUERY_STRING'].empty?
    else
      query_string = Rack::App::Utils.encode_www_form(params.to_a)
      url = [url, query_string].join('?')
    end

    response.status = 301
    response.headers.merge!({'Location' => url})

    finish!

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rack-app-5.10.1 lib/rack/app/instance_methods/redirect_to.rb
rack-app-5.10.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-5.9.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-5.8.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-5.7.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-5.7.0.rc lib/rack/app/instance_methods/redirect_to.rb
rack-app-5.6.0 lib/rack/app/instance_methods/redirect_to.rb