Class: Frank::Middleware::Refresh

Inherits:
Object
  • Object
show all
Defined in:
lib/frank/middleware/refresh.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Refresh

Returns a new instance of Refresh.


5
6
7
8
# File 'lib/frank/middleware/refresh.rb', line 5

def initialize(app, options={})
  @app     = app
  @folders = options[:watch]
end

Instance Method Details

#call(env) ⇒ Object

catch __refrank__ path and return the most recent timestamp


12
13
14
15
16
17
18
19
# File 'lib/frank/middleware/refresh.rb', line 12

def call(env)
  request = Rack::Request.new(env)
  if request.path_info.match /^\/__refresh__$/
    [ 200, { 'Content-Type' => 'application/json', 'Connection' => 'Keep-Alive', 'Keep-Alive' => 'timeout=60', 'Cache-Control' => 'max-age=0' }, "#{get_mtime}" ]
  else
    @app.call(env)
  end
end