Class: Conjur::WebServer::Home
- Inherits:
-
Object
- Object
- Conjur::WebServer::Home
- Defined in:
- lib/conjur/webserver/home.rb
Instance Method Summary collapse
-
#call(env) ⇒ Object
From Rack::File.
-
#initialize(root) ⇒ Home
constructor
A new instance of Home.
Constructor Details
Instance Method Details
#call(env) ⇒ Object
From Rack::File
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/conjur/webserver/home.rb', line 15 def call(env) path = File.(INDEX, @root) renderer = Renderer.new @root page = File.read(path) files = [path] last_modified = files.map(&File.method(:mtime)).max.httpdate return [304, {}, []] if env['HTTP_IF_MODIFIED_SINCE'] == last_modified size = Rack::Utils.bytesize(page) headers = { "Last-Modified" => last_modified, "Content-Type" => "text/html", "Content-Length" => size.to_s } [200, headers, env["REQUEST_METHOD"] == "HEAD" ? [] : [page]] end |