Sha256: 49c971237a5428316f0da886ff3864962e621d6679286ab4b0b1f023396ac4e8

Contents?: true

Size: 418 Bytes

Versions: 6

Compression:

Stored size: 418 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/)
          [404, { 'Content-Type' => 'application/hal+json'},[]]
        else
          response
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pact_broker-2.29.0 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.27.6 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.27.5 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.27.4 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.27.3 lib/rack/pact_broker/convert_404_to_hal.rb
pact_broker-2.27.2 lib/rack/pact_broker/convert_404_to_hal.rb