Class: Herdis::Rack::Favicon
- Inherits:
-
Object
- Object
- Herdis::Rack::Favicon
- Defined in:
- lib/herdis/rack/favicon.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, filename) ⇒ Favicon
constructor
A new instance of Favicon.
Constructor Details
#initialize(app, filename) ⇒ Favicon
Returns a new instance of Favicon.
11 12 13 14 15 16 |
# File 'lib/herdis/rack/favicon.rb', line 11 def initialize(app, filename) @app = app @favicon = File.read(File.join(filename)) @expires = Time.at(Time.now + (60 * 60 * 24 * 7)).utc.rfc822.to_s @last_modified = File.mtime(filename).utc.rfc822.to_s end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/herdis/rack/favicon.rb', line 18 def call(env) if env['REQUEST_PATH'] == '/favicon.ico' env.logger.info('Serving favicon.ico') [200, {'Last-Modified' => @last_modified, 'Expires' => @expires, 'Content-Type' => "image/png"}, @favicon] else @app.call(env) end end |