Class: DefaultHeaderMiddleware

Inherits:
Object
  • Object
show all
Defined in:
worklog/webserver.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ DefaultHeaderMiddleware

Rack middleware to add default headers to the response.



15
16
17
# File 'worklog/webserver.rb', line 15

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
# File 'worklog/webserver.rb', line 19

def call(env)
  status, headers, body = @app.call(env)
  headers[Rack::CONTENT_TYPE] ||= 'text/html'
  headers[Rack::CACHE_CONTROL] ||= 'no-cache'
  [status, headers, body]
end