From a52fadf71511f4f694d019134fcfd23161d9a142 Mon Sep 17 00:00:00 2001 From: Hakan Ensari Date: Mon, 26 Nov 2012 19:36:37 +0000 Subject: [PATCH] Use api subdomain for api reqs --- lib/app.rb | 8 ++++++++ public/index.html | 30 ++++++++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/lib/app.rb b/lib/app.rb index 0933208..6e683d6 100644 --- a/lib/app.rb +++ b/lib/app.rb @@ -6,6 +6,12 @@ require 'yajl' set :root, File.expand_path('..', File.dirname(__FILE__)) helpers do + def redirect_to_api + if request.host =~ /^f/ + redirect request.url.sub %r(://f), '://api.f' + end + end + # Ugly as fuck. def snapshot symbols = params.delete('symbols') || params.delete('currencies') @@ -28,10 +34,12 @@ get '/' do end get '/latest' do + redirect_to_api if production? jsonp snapshot end get '/:date' do + redirect_to_api if production? jsonp snapshot end diff --git a/public/index.html b/public/index.html index 3abe983..7d06944 100644 --- a/public/index.html +++ b/public/index.html @@ -82,42 +82,48 @@ euro.

- curl http://fixer.io/latest + curl http://api.fixer.io/latest

Get historical rates for any day since 1999.

- curl http://fixer.io/2000-01-03 + curl http://api.fixer.io/2000-01-03

- Quote against a currency, both real-time and historically, by setting - the base parameter in your request. + Quote against a currency by setting the base parameter + in your request.

- curl http://fixer.io/latest?base=USD + curl http://api.fixer.io/latest?base=USD

- Request specific exchange rates, both real-time and historically, by - setting the symbols or currencies - parameter. + Request specific exchange rates by setting the + symbols or currencies parameter.

- curl http://fixer.io/latest?symbols=USD,GBP + curl http://api.fixer.io/latest?symbols=USD,GBP

- Make cross-domain JSONP requests. + Make cross-domain JSONP requests.

- curl http://fixer.io/latest?callback=myCallback + curl http://api.fixer.io/latest?callback=myCallback

- Exchange rates are usually updated by 3pm CET. + HTTPS endpoints are available. +

+ + curl https://api.fixer.io/latest + + +

+ Exchange rates are usually updated by 3pm CET.