From db209f50b58cb037385214cf17af2fc6949c35ca Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Fri, 15 Apr 2016 16:34:49 +0200 Subject: [PATCH] Parse index key from hostname My goal is to use the branch name as the subdomain, this is a step toward that. --- waiter/lib/travis/web/app.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/waiter/lib/travis/web/app.rb b/waiter/lib/travis/web/app.rb index de6661fa..a21060f9 100644 --- a/waiter/lib/travis/web/app.rb +++ b/waiter/lib/travis/web/app.rb @@ -76,7 +76,7 @@ class Travis::Web::App # route req = Rack::Request.new(env) - response_for("index.html", {params: req.params}) + response_for("index.html", {params: req.params, host: req.host}) end private @@ -126,7 +126,10 @@ class Travis::Web::App if index?(file) redis = Redis.new project = 'travis' - index_key = options[:params]["index_key"] || redis.get("#{project}:index:current") + + host = options[:host] + + index_key = host.split('.')[0] || redis.get("#{project}:index:current") redis.get("#{project}:index:#{index_key}") else content = File.read(file)