Sha256: 9b80d8aabd61a415e360c1c90de396bfcb299e25337c7fc9d15e0f597e769749

Contents?: true

Size: 697 Bytes

Versions: 6

Compression:

Stored size: 697 Bytes

Contents

# frozen-string-literal: true

#
class Roda
  module RodaPlugins
    # The status_303 plugin sets the default redirect status to be 303
    # rather than 302 when the request is not a GET and the
    # redirection occurs on an HTTP 1.1 connection as per RFC 7231.
    # There are some frontend frameworks that require this behavior.
    #
    # Example:
    #
    #   plugin :status_303
    module Status303
      module RequestMethods

        private

        def default_redirect_status
          if env['HTTP_VERSION'] == 'HTTP/1.1' && !is_get?
            303
          else
            super
          end
        end
      end
    end

    register_plugin(:status_303, Status303)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
roda-3.55.0 lib/roda/plugins/status_303.rb
roda-3.54.0 lib/roda/plugins/status_303.rb
roda-3.53.0 lib/roda/plugins/status_303.rb
roda-3.52.0 lib/roda/plugins/status_303.rb
roda-3.51.0 lib/roda/plugins/status_303.rb
roda-3.50.0 lib/roda/plugins/status_303.rb