class SiteDiff::Webserver::ResultServer::CacheServlet
Display a page from the cache
Public Class Methods
new(_server, cache)
click to toggle source
Creates a Cache
Servlet.
# File lib/sitediff/webserver/resultserver.rb, line 16 def initialize(_server, cache) @cache = cache end
Public Instance Methods
do_GET(req, res)
click to toggle source
Performs a GET request.
# File lib/sitediff/webserver/resultserver.rb, line 22 def do_GET(req, res) path = req.path_info (md = %r{^/([^/]+)(/.*)$}.match(path)) || raise(WEBrick::HTTPStatus::NotFound) tag, path = *md.captures (r = @cache.get(tag.to_sym, path)) || raise(WEBrick::HTTPStatus::NotFound) raise WEBrick::HTTPStatus[r.error_code] if r.error_code raise WEBrick::HTTPStatus::InternalServerError, r.error if r.error res['content-type'] = 'text/html' res.body = r.content end