-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.rb
executable file
·63 lines (53 loc) · 1.28 KB
/
application.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
#!/usr/bin/env ruby
# encoding: utf-8
require File.dirname(__FILE__) + '/environment.rb'
class BIONOMIAAPI < Sinatra::Base
set :root, File.dirname(__FILE__)
set :haml, :format => :html5
set :public_folder, 'public'
set :show_exceptions, false
set :protection, :except => [:json_csrf]
register Sinatra::MultiRoute
register Config
include Pagy::Backend
include Pagy::Frontend
Pagy::DEFAULT[:limit] = 30
helpers Sinatra::BionomiaApi::Formatters
helpers Sinatra::BionomiaApi::Queries
helpers Sinatra::BionomiaApi::Reconcile
helpers Sinatra::BionomiaApi::UserHelper
helpers Sinatra::BionomiaApi::DatasetHelper
register Sinatra::BionomiaApi::Controller::SearchController
register Sinatra::BionomiaApi::Controller::ReconcileController
error Sinatra::NotFound do
if !content_type
haml :oops
else
content_type "application/json", charset: 'utf-8'
status 404
{
errors: [
{
status: 404
}
]
}.to_json
end
end
error do
if !content_type
haml :oops
else
content_type "application/json", charset: 'utf-8'
status 503
{
errors: [
{
status: 503
}
]
}.to_json
end
end
run! if app_file == $0
end