Class: Conjur::WebServer::Home
- Inherits:
-
Object
- Object
- Conjur::WebServer::Home
- Defined in:
- lib/conjur/webserver/home.rb
Constant Summary collapse
- F =
::File
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 |
# File 'lib/conjur/webserver/home.rb', line 15 def call(env) path = File.("index.html", @root) if env["REQUEST_METHOD"] == "OPTIONS" return [200, {'Allow' => ALLOW_HEADER, 'Content-Length' => '0'}, []] end last_modified = F.mtime(path).httpdate return [304, {}, []] if env['HTTP_IF_MODIFIED_SINCE'] == last_modified size = F.size?(path) || Rack::Utils.bytesize(F.read(path)) headers = { "Last-Modified" => last_modified, "Content-Type" => "text/html", "Content-Length" => size.to_s } [ 200, headers, env["REQUEST_METHOD"] == "HEAD" ? [] : [ F.read(path) ] ] end |