Class: Goliath::Rack::Favicon
- Inherits:
-
Object
- Object
- Goliath::Rack::Favicon
- Defined in:
- lib/goliath/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/goliath/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/goliath/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/vnd.microsoft.icon"}, @favicon] else @app.call(env) end end |