-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
35 lines (27 loc) · 871 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module BounceHammerAPI
class App < Sinatra::Application
configure do
disable :method_override
disable :static
# Really basic/simple Sinatra session settings:
set :sessions, httponly: true,
expire_after: 31557600, # aka one year
secure: production?,
secret: ENV['SINATRA_SESSION_SECRET']
set :server, :puma
end
use Rack::Deflater
get '/data/recent/:number/?:unit' do
content_type :json
DataDumper.new({
'howrecent' => "#{params['number']}#{params['unit'] || ''}"
}).results
end
get '/data/*' do
content_type :json
converter = ConvertsArgFormat.new(DataDumperOptions.new)
args_hash = converter.splat_to_hash(params[:splat])
DataDumper.new(args_hash).results
end
end
end