mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-11-22 11:02:30 +01:00
Add Last Modified header
This commit is contained in:
parent
c1f2ed25e7
commit
5094956f7c
@ -53,11 +53,14 @@ get '/' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
get '/latest' do
|
get '/latest' do
|
||||||
|
last_modified quote[:date]
|
||||||
jsonp quote
|
jsonp quote
|
||||||
end
|
end
|
||||||
|
|
||||||
get(/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/) do
|
get(/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/) do
|
||||||
transform_date
|
transform_date
|
||||||
|
last_modified quote[:date]
|
||||||
|
|
||||||
jsonp quote
|
jsonp quote
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,6 +40,16 @@ describe 'the API' do
|
|||||||
json['rates'].wont_be :empty?
|
json['rates'].wont_be :empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns a last modified header for latest quote' do
|
||||||
|
get '/latest'
|
||||||
|
headers['Last-Modified'].wont_be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns a last modified header for historical quote' do
|
||||||
|
get '/2012-11-20'
|
||||||
|
headers['Last-Modified'].wont_be_nil
|
||||||
|
end
|
||||||
|
|
||||||
it 'allows cross-origin requests' do
|
it 'allows cross-origin requests' do
|
||||||
get '/', {}, 'HTTP_ORIGIN' => 'http://localhost'
|
get '/', {}, 'HTTP_ORIGIN' => 'http://localhost'
|
||||||
assert_equal 'http://localhost', headers['Access-Control-Allow-Origin']
|
assert_equal 'http://localhost', headers['Access-Control-Allow-Origin']
|
||||||
|
Loading…
Reference in New Issue
Block a user