Class: Rack::PactBroker::Convert404ToHal
- Inherits:
-
Object
- Object
- Rack::PactBroker::Convert404ToHal
- Defined in:
- lib/rack/pact_broker/convert_404_to_hal.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Convert404ToHal
constructor
A new instance of Convert404ToHal.
Constructor Details
#initialize(app) ⇒ Convert404ToHal
Returns a new instance of Convert404ToHal.
5 6 7 |
# File 'lib/rack/pact_broker/convert_404_to_hal.rb', line 5 def initialize app @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/rack/pact_broker/convert_404_to_hal.rb', line 9 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 |