Class: Faraday::Multipart::Middleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Faraday::Multipart::Middleware
- Defined in:
- lib/faraday/multipart/middleware.rb
Overview
Middleware for supporting multi-part requests.
Constant Summary collapse
- CONTENT_TYPE =
'Content-Type'
- DEFAULT_BOUNDARY_PREFIX =
'-----------RubyMultipartPost'
Instance Method Summary collapse
-
#call(env) ⇒ Object
Checks for files in the payload, otherwise leaves everything untouched.
-
#initialize(app = nil, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app = nil, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
12 13 14 15 |
# File 'lib/faraday/multipart/middleware.rb', line 12 def initialize(app = nil, = {}) super(app) @options = end |
Instance Method Details
#call(env) ⇒ Object
Checks for files in the payload, otherwise leaves everything untouched.
20 21 22 23 24 25 26 27 28 |
# File 'lib/faraday/multipart/middleware.rb', line 20 def call(env) match_content_type(env) do |params| env.request.boundary ||= unique_boundary env.request_headers[CONTENT_TYPE] += "; boundary=#{env.request.boundary}" env.body = create_multipart(env, params) end @app.call env end |