forked from shrinerb/shrine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
38 lines (29 loc) · 749 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
36
37
38
require "roda"
require "./routes/albums"
require "./routes/direct_upload"
require "./uploaders/image_uploader"
class ShrineDemo < Roda
plugin :public
plugin :assets, css: "app.css", js: "app.js"
plugin :run_handler
use Rack::Session::Cookie, secret: "secret"
plugin :route_csrf, check_header: true
route do |r|
r.public # serve static assets
r.assets # serve dynamic assets
check_csrf!
# redirect '/' to '/albums'
r.root do
r.redirect "/albums", 301
end
# all '/albums'
r.on "albums" do
r.run Routes::Albums
end
r.on "derivations/image" do
r.run ImageUploader.derivation_endpoint
end
# all other routes
r.run Routes::DirectUpload, not_found: :pass
end
end