Class: Fyb::Middleware::Parser
- Inherits:
-
Object
- Object
- Fyb::Middleware::Parser
- Includes:
- Rack::Utils
- Defined in:
- lib/fyb/middleware/parser.rb
Overview
Correct the Content-Type of the replies from Fyb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(app) ⇒ Parser
Returns a new instance of Parser.
7 8 9 |
# File 'lib/fyb/middleware/parser.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fyb/middleware/parser.rb', line 11 def call(env) status, headers, response = @app.call(env) headers = HeaderHash.new(headers) if headers.key?('Content-Type') && headers['Content-Type'].include?('text/html; charset=utf-8') headers['Content-Type'] = [headers['Content-Type'][0].gsub('text/html', 'application/json')] end [status, headers, response] end |