Root returns link to docs

This commit is contained in:
Hakan Ensari 2020-05-02 19:38:36 +01:00
parent 1116343424
commit 7e2c69132d
3 changed files with 14 additions and 5 deletions

View File

@ -4,10 +4,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] ## [Unreleased]
### Changed ### Changed
- Root returns link to docs
- Handle rounding edge case where a lower-rate base currency like IDR produces less precise quotes - Handle rounding edge case where a lower-rate base currency like IDR produces less precise quotes
- Sample weekly when querying over a year - Sample weekly when querying over a year
- Bump PostgreSQL to 12 - Bump PostgreSQL to 12
### Fixed
- Set charset to UTF-8
## 1.0.0 - 2020-01-02 ## 1.0.0 - 2020-01-02
### Fixed ### Fixed
- Start versioning images so users can track changes - Start versioning images so users can track changes

View File

@ -57,17 +57,17 @@ helpers do
callback = params['callback'] callback = params['callback']
if callback if callback
content_type :js content_type :js, charset: Encoding::UTF_8
"#{callback}(#{json})" "#{callback}(#{json})"
else else
content_type :json content_type :json, charset: Encoding::UTF_8
json json
end end
end end
end end
get '/' do get '/' do
redirect 'https://www.frankfurter.app', 301 json({ docs: 'https://wwww.frankfurter.app/docs' })
end end
get '/(?:latest|current)', mustermann_opts: { type: :regexp } do get '/(?:latest|current)', mustermann_opts: { type: :regexp } do

View File

@ -11,9 +11,9 @@ describe 'the server' do
let(:json) { Oj.load(last_response.body) } let(:json) { Oj.load(last_response.body) }
let(:headers) { last_response.headers } let(:headers) { last_response.headers }
it 'redirects root to documentation site' do it 'returns link to docs' do
get '/' get '/'
_(last_response).must_be :redirect? _(json['docs']).wont_be_nil
end end
it 'returns latest quotes' do it 'returns latest quotes' do
@ -102,4 +102,9 @@ describe 'the server' do
get '/latest?callback=foo' get '/latest?callback=foo'
_(last_response.body).must_be :start_with?, 'foo' _(last_response.body).must_be :start_with?, 'foo'
end end
it 'sets charset to UTF-8' do
get '/currencies'
_(last_response.headers['content-type']).must_be :end_with?, 'charset=UTF-8'
end
end end