-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
59 lines (45 loc) · 1.19 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require_relative 'models'
require 'roda'
class App < Roda
opts[:check_dynamic_arity] = false
opts[:check_arity] = :warn
plugin :default_headers,
'Content-Type' => 'text/html',
# 'Strict-Transport-Security'=>'max-age=16070400;', # Uncomment if only allowing https:// access
'X-Frame-Options' => 'deny',
'X-Content-Type-Options' => 'nosniff',
'X-XSS-Protection' => '1; mode=block'
plugin :hash_routes
logger = if ENV['RACK_ENV'] == 'test'
Class.new { def write(_) end }.new
else
$stderr
end
plugin :common_logger, logger
plugin :not_found do
'Not Found'
end
plugin :exception_page if ENV['RACK_ENV'] == 'development'
plugin :error_handler do |e|
$stderr.print "#{e.class}: #{e.message}\n"
warn e.backtrace
next exception_page(e) if ENV['RACK_ENV'] == 'development'
'Server Error'
end
plugin :json
Unreloader.require('routes') {}
# TODO: fix me
# hash_routes '/api' do
# get 'records' do
# Record.all
# end
# end
# r.hash_routes
route do |r|
r.on 'api' do
r.get 'records' do
Record.all.map(&:values)
end
end
end
end