Class: Olelo::Middleware::DegradeMimeType
- Defined in:
- lib/olelo/middleware/degrade_mime_type.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ DegradeMimeType
constructor
A new instance of DegradeMimeType.
Constructor Details
#initialize(app) ⇒ DegradeMimeType
Returns a new instance of DegradeMimeType.
4 5 6 |
# File 'lib/olelo/middleware/degrade_mime_type.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/olelo/middleware/degrade_mime_type.rb', line 8 def call(env) status, header, body = @app.call(env) if header['Content-Type'] && header['Content-Type'] =~ %r{\Aapplication/xhtml\+xml(;?.*)\Z} charset = $1 if env['HTTP_ACCEPT'].to_s !~ %r{application/xhtml\+xml} header['Content-Type'] = "text/html#{charset}" end end [status, header, body] end |