Class: FaradayMiddleware::XmlContentType

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/faraday_middleware/request/xml_content_type.rb

Constant Summary collapse

CONTENT_TYPE =
'Content-Type'
TEXT_XML =
'text/xml'

Instance Method Summary collapse

Constructor Details

#initialize(app, *args) ⇒ XmlContentType

Returns a new instance of XmlContentType.



9
10
11
# File 'lib/faraday_middleware/request/xml_content_type.rb', line 9

def initialize(app, *args)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
# File 'lib/faraday_middleware/request/xml_content_type.rb', line 13

def call(env)
  if [:post, :put].include? env[:method]
    env[:request_headers].merge!(CONTENT_TYPE => TEXT_XML)
  end
  @app.call env
end