-
Notifications
You must be signed in to change notification settings - Fork 981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move json middleware (request and response) from faraday_middleware #1300
Conversation
Ruby 3 seems to have some unwanted behaviour about arguments, is that around kwargs? |
It's the dependency loader, even adding |
I'm gonna finish this up once #1301 gets merged 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonderful!
self.headers = serialised[:headers] | ||
self.path = serialised[:path] | ||
self.params = serialised[:params] | ||
self.options = serialised[:options] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this change!
lib/faraday/request/json.rb
Outdated
|
||
def process_request?(env) | ||
type = request_type(env) | ||
body?(env) && (type.empty? || MIME_TYPE_REGEX =~ type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ruby version question: Can we use #match?
here?
lib/faraday/response/json.rb
Outdated
def process_response_type?(env) | ||
type = response_type(env) | ||
@content_types.empty? || @content_types.any? do |pattern| | ||
pattern.is_a?(Regexp) ? type =~ pattern : type == pattern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, perhaps too, an opportunity for #match?
spec/faraday/response/json_spec.rb
Outdated
let(:options) { {} } | ||
let(:headers) { {} } | ||
let(:middleware) do | ||
puts options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is debug output, perhaps it can be removed?
Co-authored-by: Olle Jonsson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Description
The JSON middleware, both request and response ones, are between the most used and require no external dependency since the
json
module is part of Ruby.For this reason, we can safely move it inside Faraday.
Tests have also been moved and the Website documentation have been updated.
Todos
List any remaining work that needs to be done, i.e: