Fail fast if response is empty

This commit is contained in:
Dan Buch 2015-08-27 00:51:56 -04:00
parent c47a222c83
commit 05eaee6d11

View File

@ -8,6 +8,8 @@ class CPIFeed < Sinatra::Base
get '/' do
resp = JSON.parse(Faraday.get(cpi_series_url).body)
halt 502 unless resp['Results']['series']
expires 300, :public, :must_revalidate
content_type :csv
"cpi\n#{resp['Results']['series'].first['data'].first['value']}\n"