Sha256: 5f9e742ae6be10589be724e1f6e897420e0562c36dc2a73858399d6e43a8ffc7

Contents?: true

Size: 594 Bytes

Versions: 39

Compression:

Stored size: 594 Bytes

Contents

# https://guides.rubyonrails.org/configuring.html#config-exceptions-app
module PandaCms
  class ExceptionsApp
    def initialize(exceptions_app:)
      @exceptions_app = exceptions_app
    end

    def call(env)
      request = ActionDispatch::Request.new(env)

      fallback_to_html_format_if_invalid_mime_type(request)

      @exceptions_app.call(env)
    end

    private

    def fallback_to_html_format_if_invalid_mime_type(request)
      request.formats
    rescue ActionDispatch::Http::MimeNegotiation::InvalidType
      request.set_header "CONTENT_TYPE", "text/html"
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
panda_cms-0.3.10 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.9 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.8 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.7 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.6 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.5 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.4 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.3 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.2 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.1 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.0 lib/panda_cms/exceptions_app.rb
panda_cms-0.2.7 lib/panda_cms/exceptions_app.rb
panda_cms-0.2.6 lib/panda_cms/exceptions_app.rb
panda_cms-0.2.5 lib/panda_cms/exceptions_app.rb
panda_cms-0.2.4 lib/panda_cms/exceptions_app.rb
panda_cms-0.2.3 lib/panda_cms/exceptions_app.rb
panda_cms-0.2.2 lib/panda_cms/exceptions_app.rb
panda_cms-0.2.1 lib/panda_cms/exceptions_app.rb
panda_cms-0.2.0 lib/panda_cms/exceptions_app.rb