Class: Psc::Faraday::StringIsXml
- Inherits:
-
Object
- Object
- Psc::Faraday::StringIsXml
- Defined in:
- lib/psc/faraday/string_is_xml.rb
Overview
Middleware which sets the request content type to text/xml
if
the provided body is a String
and the content type isn't
already set.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Sets the content type request header if appropriate.
-
#initialize(app) ⇒ StringIsXml
constructor
A new instance of StringIsXml.
Constructor Details
#initialize(app) ⇒ StringIsXml
Returns a new instance of StringIsXml.
10 11 12 |
# File 'lib/psc/faraday/string_is_xml.rb', line 10 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
Sets the content type request header if appropriate
16 17 18 19 20 21 22 |
# File 'lib/psc/faraday/string_is_xml.rb', line 16 def call(env) if String === env[:body] env[:request_headers]['Content-Type'] ||= 'text/xml' end @app.call(env) end |