-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify Faraday config under local module instead of global prepend (#9757
) * Unify Faraday config under local module instead of global prepend * Let Vault rely on Faraday's comfortable JSON parsing
- Loading branch information
Showing
6 changed files
with
31 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module FaradayConfig | ||
def self.setup_connection(builder) | ||
# Sets headers and parses jsons automatically | ||
builder.request :json | ||
builder.response :json | ||
|
||
# Raises an error on 4xx and 5xx responses. | ||
builder.response :raise_error | ||
|
||
# Logs requests and responses. | ||
# By default, it only logs the request method and URL, and the request/response headers. | ||
builder.response :logger, ::Logger.new($stdout), bodies: true if Rails.env.development? | ||
end | ||
|
||
# This makes it so that we can just pass &FaradayConfig | ||
# as an arg directly to the last parameter of the Faraday constructor | ||
def self.to_proc | ||
self.method(:setup_connection).to_proc | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters