forked from kennethkalmer/ruote-kit
-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.ru
70 lines (48 loc) · 1 KB
/
config.ru
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
64
65
66
67
68
69
# bundler
require 'rubygems'
require 'bundler/setup'
# json
#
# try yajl-ruby first, and json after that
begin
require 'yajl'
rescue LoadError
begin
require 'json'
rescue LoadError
puts 'Please specify "gem {yajl-ruby|json_pure|json}" in the Gemfile'
exit
end
end
require 'rufus-json'
# ruote-kit
$:.unshift 'lib'
require 'ruote-kit'
# ruote
require 'ruote/storage/fs_storage'
RuoteKit.engine = Ruote::Engine.new(
Ruote::Worker.new(
Ruote::FsStorage.new(
"ruote_work_#{RuoteKit.env}")))
RuoteKit.engine.register do
catchall
end
# redirecting / to /_ruote (to avoid issue reports from new users)
class ToRuote
def initialize(app)
@app = app
end
def call(env)
if env['PATH_INFO'] == '/'
[ 303, { 'Location' => '/_ruote', 'Content-Type' => 'text/plain' }, [] ]
else
@app.call(env)
end
end
end
# rack middlewares, business as usual...
use ToRuote
use Rack::CommonLogger
use Rack::Lint
use Rack::ShowExceptions
run RuoteKit::Application