From 21d30a9ed4edd822c54be130341a48af5d47fa05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Dahl=20M=C3=B8llerh=C3=B8j?= Date: Thu, 7 Oct 2021 19:14:20 +0200 Subject: [PATCH] Register json middleware I was quite surprised to realize I had to do register this middleware manually, as I didn't have to do that for the other middleware in core. --- lib/faraday/request.rb | 1 + lib/faraday/request/json.rb | 2 ++ lib/faraday/response.rb | 1 + lib/faraday/response/json.rb | 2 ++ 4 files changed, 6 insertions(+) diff --git a/lib/faraday/request.rb b/lib/faraday/request.rb index 9a97ba79b..d139727b8 100644 --- a/lib/faraday/request.rb +++ b/lib/faraday/request.rb @@ -132,6 +132,7 @@ def to_env(connection) require 'faraday/request/authorization' require 'faraday/request/instrumentation' +require 'faraday/request/json' require 'faraday/request/multipart' require 'faraday/request/retry' require 'faraday/request/url_encoded' diff --git a/lib/faraday/request/json.rb b/lib/faraday/request/json.rb index a17a4dd06..fa219c49d 100644 --- a/lib/faraday/request/json.rb +++ b/lib/faraday/request/json.rb @@ -51,3 +51,5 @@ def request_type(env) end end end + +Faraday::Request.register_middleware(json: Faraday::Request::Json) diff --git a/lib/faraday/response.rb b/lib/faraday/response.rb index 505e4ea43..3dd1bc520 100644 --- a/lib/faraday/response.rb +++ b/lib/faraday/response.rb @@ -85,5 +85,6 @@ def apply_request(request_env) end end +require 'faraday/response/json' require 'faraday/response/logger' require 'faraday/response/raise_error' diff --git a/lib/faraday/response/json.rb b/lib/faraday/response/json.rb index 19fa72047..399b7f351 100644 --- a/lib/faraday/response/json.rb +++ b/lib/faraday/response/json.rb @@ -50,3 +50,5 @@ def response_type(env) end end end + +Faraday::Response.register_middleware(json: Faraday::Response::Json)