Class: Cannon::Middleware::ContentType

Inherits:
Object
  • Object
show all
Defined in:
lib/cannon/middleware/content_type.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ContentType

Returns a new instance of ContentType.



4
5
6
# File 'lib/cannon/middleware/content_type.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#run(request, response, next_proc) ⇒ Object



8
9
10
11
12
# File 'lib/cannon/middleware/content_type.rb', line 8

def run(request, response, next_proc)
  return next_proc.call unless response.headers['Content-Type'].nil?
  response.headers['Content-Type'] = 'text/plain; charset=us-ascii'
  next_proc.call
end