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.6.3 lib/panda_cms/exceptions_app.rb
panda_cms-0.6.2 lib/panda_cms/exceptions_app.rb
panda_cms-0.6.1 lib/panda_cms/exceptions_app.rb
panda_cms-0.6.0 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.10 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.9 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.8 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.7 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.6 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.5 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.4 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.3 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.2 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.1 lib/panda_cms/exceptions_app.rb
panda_cms-0.5.0 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.15 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.14 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.13 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.12 lib/panda_cms/exceptions_app.rb
panda_cms-0.3.11 lib/panda_cms/exceptions_app.rb