Class: NonCachingFileHandler

Inherits:
WEBrick::HTTPServlet::FileHandler
  • Object
show all
Defined in:
lib/hanoi/webrick.rb

Instance Method Summary collapse

Instance Method Details

#do_GET(req, res) ⇒ Object



89
90
91
92
93
# File 'lib/hanoi/webrick.rb', line 89

def do_GET(req, res)
  super
  set_default_content_type(res, req.path)
  prevent_caching(res)
end

#set_default_content_type(res, path) ⇒ Object



95
96
97
98
99
100
101
102
# File 'lib/hanoi/webrick.rb', line 95

def set_default_content_type(res, path)
  res['Content-Type'] = case path
    when /\.js$/   then 'text/javascript'
    when /\.html$/ then 'text/html'
    when /\.css$/  then 'text/css'
    else 'text/plain'
  end
end