Class: Rack::Gist

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/gist.rb

Constant Summary collapse

DefaultCacheTime =
3600

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Gist.



8
9
10
11
# File 'lib/rack/gist.rb', line 8

def initialize(app, options = {})
  @app = app
  @options = options
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/rack/gist.rb', line 13

def call(env)
  if path(env).match(regex)
    serve_gist(env)
  else
    status, headers, body = @app.call(env)
    rewrite(status, headers, body)
  end
end