Add index key option for Redis front-end

This commit is contained in:
Buck Doyle 2016-04-14 18:10:01 +02:00
parent 84ac5f2abf
commit dfb80470f6

View File

@ -75,7 +75,8 @@ class Travis::Web::App
# route[1]["Date"] = Time.now.httpdate # route[1]["Date"] = Time.now.httpdate
# route # route
response_for("index.html") req = Rack::Request.new(env)
response_for("index.html", {params: req.params})
end end
private private
@ -92,7 +93,7 @@ class Travis::Web::App
end end
def response_for(file, options = {}) def response_for(file, options = {})
content = content_for(file) content = content_for(file, options)
if fingerprinted?(file) if fingerprinted?(file)
headers = { headers = {
'Content-Length' => content.bytesize.to_s, 'Content-Length' => content.bytesize.to_s,
@ -121,11 +122,11 @@ class Travis::Web::App
[ 200, headers, [content] ] [ 200, headers, [content] ]
end end
def content_for(file) def content_for(file, options)
if index?(file) if index?(file)
redis = Redis.new redis = Redis.new
project = 'travis' project = 'travis'
index_key = redis.get("#{project}:index:current") index_key = options[:params]["index_key"] || redis.get("#{project}:index:current")
redis.get("#{project}:index:#{index_key}") redis.get("#{project}:index:#{index_key}")
else else
content = File.read(file) content = File.read(file)