Redirect to S3 file

This commit is contained in:
Dan Buch 2015-09-13 23:02:37 -04:00
parent 808cd318ee
commit cece28eaf8
4 changed files with 4 additions and 34 deletions

View File

@ -3,6 +3,6 @@ source 'https://rubygems.org'
ruby '2.2.2' if ENV.key?('DYNO')
gem 'aws-sdk', '~> 2'
gem 'puma'
gem 'pry', group: [:development, :test]
gem 'sinatra'
gem 'puma'
gem 'rack'

View File

@ -18,14 +18,7 @@ GEM
slop (~> 3.4)
puma (2.13.4)
rack (1.6.4)
rack-protection (1.5.3)
rack
sinatra (1.4.6)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
slop (3.6.0)
tilt (2.0.1)
PLATFORMS
ruby
@ -34,7 +27,7 @@ DEPENDENCIES
aws-sdk (~> 2)
pry
puma
sinatra
rack
BUNDLED WITH
1.10.6

21
app.rb
View File

@ -1,21 +0,0 @@
require 'sinatra/base'
require_relative 'cpi_fetcher'
class App < Sinatra::Base
get '/' do
current_cpi = fetcher.cpi
halt 502 unless current_cpi
expires 300, :public, :must_revalidate
content_type :text
"#{current_cpi}\n"
end
run! if app_file == $PROGRAM_FILE
private
def fetcher
@fetcher ||= CPIFetcher.new
end
end

View File

@ -1,3 +1 @@
require './app'
run App
run lambda { |env| [301, { 'Location' => ENV['CPI_FEED_URL'] }, []] }