class Fyb::Middleware::Parser
Correct the Content-Type of the replies from Fyb
Public Class Methods
new(app)
click to toggle source
# File lib/fyb/middleware/parser.rb, line 7 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# 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