-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
63 lines (51 loc) · 1.02 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
60
61
62
63
require_relative 'config/env'
require_relative 'lib/roda_utils'
require_relative 'lib/view_helpers'
class App < Roda
plugin :render, engine: 'haml'
plugin :multi_route
plugin :partials
plugin :all_verbs
plugin :not_found
plugin :error_handler
plugin :public
plugin :json
plugin :json_parser
include RodaUtils
include ViewHelpers
route do |r|
r.root {
# TODO: use sucker-punch or async
Thread.new { MIX.track 'anonymous', 'homepage-visit' }
view 'index'
}
r.on("health") {
r.get {
{ status: "ok" }
}
r.head {
{ status: "ok" }
}
}
r.get("videos") {
Thread.new { MIX.track 'anonymous', 'videos-page-visit' }
view 'videos'
}
r.public if ENV["SERVE_ASSETS"] == "1" || APP_ENV != "production"
end
not_found do
view "not_found"
end
error do |err|
case err
when nil
# catch a proper error...
#
# when CustomError
# "ERR" # like so
else
raise err
end
end
freeze
end