Class: Aardi::PathServlet
- Inherits:
-
WEBrick::HTTPServlet::AbstractServlet
- Object
- WEBrick::HTTPServlet::AbstractServlet
- Aardi::PathServlet
- Defined in:
- lib/aardi/path_servlet.rb
Instance Method Summary collapse
Instance Method Details
#service(req, res) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/aardi/path_servlet.rb', line 7 def service(req, res) # use index if folder path = "./#{req.path}".sub(%r{/$}, '/index.html') file = path if File.exist?(path) file ||= "#{path}.html" if File.exist?("#{path}.html") raise(WEBrick::HTTPStatus::NotFound, "#{path} not found.") unless file res.body = File.read(file) end |