Sha256: 86cf109b77baf6d3fb619f0b4e5ba4d03e784a545357ce8c38ab20971cac66ca

Contents?: true

Size: 419 Bytes

Versions: 15

Compression:

Stored size: 419 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['Location']= url

    finish!

  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rack-app-6.6.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-6.5.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-6.4.1 lib/rack/app/instance_methods/redirect_to.rb
rack-app-6.4.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-6.3.3 lib/rack/app/instance_methods/redirect_to.rb
rack-app-6.3.2 lib/rack/app/instance_methods/redirect_to.rb
rack-app-6.3.1 lib/rack/app/instance_methods/redirect_to.rb
rack-app-6.3.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-6.2.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-6.1.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-6.0.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-5.12.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-5.11.1 lib/rack/app/instance_methods/redirect_to.rb
rack-app-5.11.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-5.10.2 lib/rack/app/instance_methods/redirect_to.rb