forked from torquebox/backstage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backstage.rb
103 lines (87 loc) · 2.57 KB
/
backstage.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#
# Copyright 2011 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'sinatra/base'
require 'rack-flash'
require 'rack/accept'
require 'haml'
require 'sass'
require 'jmx'
$:.unshift File.join( File.dirname( __FILE__ ), 'lib' )
require 'torquebox'
require 'resource_helpers'
require 'resource'
require 'helpers'
require 'has_mbean'
require 'torquebox_managed'
require 'pools'
require 'apps'
require 'destinations'
require 'message_processors'
require 'jobs'
require 'logs'
require 'services'
require 'caches'
require 'groups'
Backstage.logger.warn "ENV['REQUIRE_AUTHENTICATION'] is not set, *disabling* authentication" unless ENV['REQUIRE_AUTHENTICATION']
module Backstage
BACKSTAGE_VERSION = File.readlines( File.join( File.dirname( __FILE__ ), 'VERSION' ) ).first.strip
TORQUEBOX_VERSION = File.readlines( File.join( File.dirname( __FILE__ ), 'TORQUEBOX_VERSION' ) ).first.strip
class Application < Sinatra::Base
enable :sessions
use Rack::Accept
use Rack::Flash
use Rack::CommonLogger, Backstage.logger
include Backstage::Authentication
set :views, Proc.new { File.join( File.dirname( __FILE__ ), "views" ) }
COLLECTIONS = [
:apps,
:caches,
:groups,
:jobs,
:logs,
:message_processors,
:pools,
:queues,
:services,
:topics
]
before do
require_authentication if ENV['REQUIRE_AUTHENTICATION']
end
get '/api' do
content_type :json
{
:collections => COLLECTIONS.inject({}) do |collections, collection|
collections[collection] = json_url_for( collection_path( collection ) )
collections
end
}.to_json
end
get '/' do
if html_requested?
haml :'dashboard/index'
else
redirect_to '/url'
end
end
get '/css/style.css' do
sass :'css/style'
end
get '/css/html5reset.css' do
sass :'css/html5reset'
end
end
end