cpi-feed/app.rb

22 lines
357 B
Ruby

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