-
Notifications
You must be signed in to change notification settings - Fork 35
Closed
Labels
Description
If you are making a request from a spec with setup that is something like this
Hyperclient.new('http://example.org/') do |client|
client.connection(default: false) do |conn|
conn.request :json
conn.response :json
conn.use Faraday::Adapter::Rack, app
end
end
FaradayMiddleware::EncodeJson will not convert the request to json because it isn't aware of 'application/hal+json'
We monkeypatched it locally to work around the problem but it still isn't pretty.
module FaradayMiddleware
class EncodeJson < Faraday::Middleware
MIME_TYPE = 'application/hal+json'.freeze
end
end
Alternatively, resetting the client's content type to application/json will work.
Hyperclient.new('http://example.org/') do |client|
client.headers['Content-Type'] = 'application/json'
client.connection(default: false) do |conn|
conn.request :json
conn.response :json
conn.use Faraday::Adapter::Rack, app
end
end