mirror of
https://github.com/gwenhael-le-moine/ledgerrb.git
synced 2025-02-04 20:46:33 +01:00
utf-8 response
This commit is contained in:
parent
7993c9c6fd
commit
09678bd48e
1 changed files with 9 additions and 14 deletions
23
app.rb
23
app.rb
|
@ -10,25 +10,26 @@ require_relative './lib/ledger'
|
||||||
class LedgerRbApp < Sinatra::Base
|
class LedgerRbApp < Sinatra::Base
|
||||||
helpers Sinatra::Param
|
helpers Sinatra::Param
|
||||||
|
|
||||||
|
before do
|
||||||
|
content_type :json, 'charset' => 'utf-8'
|
||||||
|
end
|
||||||
|
|
||||||
get '/' do
|
get '/' do
|
||||||
|
content_type :html
|
||||||
send_file './public/app/index.html'
|
send_file './public/app/index.html'
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/api/ledger/accounts/?' do
|
get '/api/ledger/accounts/?' do
|
||||||
content_type :json
|
|
||||||
|
|
||||||
Ledger.accounts.to_json
|
Ledger.accounts.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/api/ledger/accounts/depth/:depth/?' do
|
get '/api/ledger/accounts/depth/:depth/?' do
|
||||||
content_type :json
|
|
||||||
param :depth, Integer, required: true
|
param :depth, Integer, required: true
|
||||||
|
|
||||||
Ledger.accounts( params[ :depth ] ).to_json
|
Ledger.accounts( params[ :depth ] ).to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/api/ledger/register/:period/?' do
|
get '/api/ledger/register/:period/?' do
|
||||||
content_type :json
|
|
||||||
param :period, String, required: true # TODO: restrict possible values to [ 'yearly', 'monthly' ]
|
param :period, String, required: true # TODO: restrict possible values to [ 'yearly', 'monthly' ]
|
||||||
param :categories, Array, default: Ledger.accounts( 1 )
|
param :categories, Array, default: Ledger.accounts( 1 )
|
||||||
|
|
||||||
|
@ -41,29 +42,23 @@ class LedgerRbApp < Sinatra::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/api/ledger/balance/?' do
|
get '/api/ledger/balance/?' do
|
||||||
content_type :json
|
Ledger.balance # .to_json
|
||||||
|
|
||||||
Ledger.balance#.to_json
|
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/api/ledger/balance/depth/:depth/?' do
|
get '/api/ledger/balance/depth/:depth/?' do
|
||||||
content_type :json
|
|
||||||
param :depth, Integer, required: true
|
param :depth, Integer, required: true
|
||||||
|
|
||||||
Ledger.balance( false, params[ :depth ] )#.to_json
|
Ledger.balance( false, params[ :depth ] ) # .to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/api/ledger/cleared/?' do
|
get '/api/ledger/cleared/?' do
|
||||||
content_type :json
|
Ledger.balance( true ) # .to_json
|
||||||
|
|
||||||
Ledger.balance( true )#.to_json
|
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/api/ledger/cleared/depth/:depth/?' do
|
get '/api/ledger/cleared/depth/:depth/?' do
|
||||||
content_type :json
|
|
||||||
param :depth, Integer, required: true
|
param :depth, Integer, required: true
|
||||||
|
|
||||||
Ledger.balance( true, params[ :depth ] )#.to_json
|
Ledger.balance( true, params[ :depth ] ) # .to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/api/ledger/version/?' do
|
get '/api/ledger/version/?' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue