utf-8 response

This commit is contained in:
Gwenhael Le Moine 2014-07-28 11:35:55 +02:00
parent 7993c9c6fd
commit 09678bd48e

23
app.rb
View file

@ -10,25 +10,26 @@ require_relative './lib/ledger'
class LedgerRbApp < Sinatra::Base
helpers Sinatra::Param
before do
content_type :json, 'charset' => 'utf-8'
end
get '/' do
content_type :html
send_file './public/app/index.html'
end
get '/api/ledger/accounts/?' do
content_type :json
Ledger.accounts.to_json
end
get '/api/ledger/accounts/depth/:depth/?' do
content_type :json
param :depth, Integer, required: true
Ledger.accounts( params[ :depth ] ).to_json
end
get '/api/ledger/register/:period/?' do
content_type :json
param :period, String, required: true # TODO: restrict possible values to [ 'yearly', 'monthly' ]
param :categories, Array, default: Ledger.accounts( 1 )
@ -41,29 +42,23 @@ class LedgerRbApp < Sinatra::Base
end
get '/api/ledger/balance/?' do
content_type :json
Ledger.balance#.to_json
Ledger.balance # .to_json
end
get '/api/ledger/balance/depth/:depth/?' do
content_type :json
param :depth, Integer, required: true
Ledger.balance( false, params[ :depth ] )#.to_json
Ledger.balance( false, params[ :depth ] ) # .to_json
end
get '/api/ledger/cleared/?' do
content_type :json
Ledger.balance( true )#.to_json
Ledger.balance( true ) # .to_json
end
get '/api/ledger/cleared/depth/:depth/?' do
content_type :json
param :depth, Integer, required: true
Ledger.balance( true, params[ :depth ] )#.to_json
Ledger.balance( true, params[ :depth ] ) # .to_json
end
get '/api/ledger/version/?' do