Class: SpreeApiContentTypeRewriter::Middleware::ContentTypeRewriter
- Inherits:
-
Object
- Object
- SpreeApiContentTypeRewriter::Middleware::ContentTypeRewriter
- Defined in:
- lib/spree_api_content_type_rewriter/middleware/content_type_rewriter.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ ContentTypeRewriter
constructor
A new instance of ContentTypeRewriter.
Constructor Details
#initialize(app) ⇒ ContentTypeRewriter
Returns a new instance of ContentTypeRewriter.
4 5 6 |
# File 'lib/spree_api_content_type_rewriter/middleware/content_type_rewriter.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 |
# File 'lib/spree_api_content_type_rewriter/middleware/content_type_rewriter.rb', line 8 def call(env) status, headers, response = @app.call(env) headers['Content-Type'] = 'application/json' if env['action_dispatch.request.path_parameters'][:format] == 'json' [status, headers, response] end |