Class: Bearcat::LegacyContentTypeMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Bearcat::LegacyContentTypeMiddleware
- Defined in:
- lib/bearcat/client.rb
Overview
This is unfortunate⦠Some of the specs pass URL-Encoded keys
(eg `{ "x[y]" => 3 }`) themselves, leading me to believe that
some apps may as well. Bearcat itself (outside of specs) does
not participate in this, but CanvasSync does.
This Regex can be used to find most cases fairly reliably: ["']\w+\[
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(*args) ⇒ LegacyContentTypeMiddleware
constructor
A new instance of LegacyContentTypeMiddleware.
Constructor Details
#initialize(*args) ⇒ LegacyContentTypeMiddleware
Returns a new instance of LegacyContentTypeMiddleware.
188 189 190 191 192 |
# File 'lib/bearcat/client.rb', line 188 def initialize(*args) super @json_middleware = Faraday::Request::Json.new(*args) @urlenc_middleware = Faraday::Request::UrlEncoded.new(*args) end |
Instance Method Details
#call(env) ⇒ Object
194 195 196 197 198 199 200 201 |
# File 'lib/bearcat/client.rb', line 194 def call(env) b = env[:body] if b.is_a?(Hash) && b.keys.any? {|k| k.to_s.include?("[") } @urlenc_middleware.call(env) else @json_middleware.call(env) end end |