Sha256: 7c60c58882262f8052b5eeafd51370f49c7e590834d431eb6a5940c8ed9f4e27

Contents?: true

Size: 447 Bytes

Versions: 35

Compression:

Stored size: 447 Bytes

Contents

module Rack
  module PactBroker
    class Convert404ToHal

      def initialize app
        @app = app
      end

      def call env
        response = @app.call(env)

        if response.first == 404 && response[1]["Content-Type"] == "text/html" && !(env["HTTP_ACCEPT"] =~ /html|javascript|css/)
          [404, { "Content-Type" => "application/hal+json;charset=utf-8"},[]]
        else
          response
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
pact_broker-2.105.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.104.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.103.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.102.2 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.102.1 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.102.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.101.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.100.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.99.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.98.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.97.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.96.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.95.1 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.95.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.94.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.93.4 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.93.3 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.93.2 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.93.1 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.93.0 lib/rack/pact_broker/convert_404_to_hal.rb