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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/appetizer/ui.rb', line 10
def self.registered app
app.set :show_exceptions, false
app.configure :production do
require "rack/ssl"
app.use Rack::SSL
end
app.configure :development do
app.use Rack::CommonLogger, App.log
end
app.set :scss, cache_location: "tmp/sass-cache", style: :compact
app.use Rack::Session::Cookie,
key: (ENV["APPETIZER_COOKIE_NAME"] || "app-session"),
secret: (ENV["APPETIZER_SESSION_SECRET"] || "app-session-secret")
app.use Rack::Protection::AuthenticityToken
app.helpers do
def created thing
halt 201, json(thing)
end
def csrf
session[:csrf] ||= SecureRandom.hex 32
end
def json thing
content_type :json, charset: "utf-8"
jsonify thing
end
def jsonify thing
Yajl::Encoder.encode thing
end
def manifest
Appetizer::UI::Assets.manifest
end
end
end
|