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.92.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.91.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.90.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.89.1 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.89.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.88.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.87.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.86.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.85.1 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.85.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.84.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.83.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.82.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.81.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.80.0 lib/rack/pact_broker/convert_404_to_hal.rb