Sha256: 0dcb1a8d1c6cd6a0e46708b63c9a5ab7c4c6e10d386b7294319f8580251d31f6

Contents?: true

Size: 411 Bytes

Versions: 31

Compression:

Stored size: 411 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::Utils.build_nested_query(params)
      url = [url, query_string].join('?')
    end

    response.status = 301
    response.headers['Location']= url

    finish!

  end

end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
rack-app-11.0.2 lib/rack/app/instance_methods/redirect_to.rb
rack-app-11.0.1 lib/rack/app/instance_methods/redirect_to.rb
rack-app-11.0.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-10.0.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-9.0.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-8.1.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-8.0.1 lib/rack/app/instance_methods/redirect_to.rb
rack-app-8.0.0 lib/rack/app/instance_methods/redirect_to.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/rack-app-7.7.0/lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.7.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.6.5 lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.6.4 lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.6.3 lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.6.2 lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.6.1 lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.6.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.5.2 lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.5.1 lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.5.0 lib/rack/app/instance_methods/redirect_to.rb
rack-app-7.4.0 lib/rack/app/instance_methods/redirect_to.rb