-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.rb
More file actions
38 lines (30 loc) · 1013 Bytes
/
app.rb
File metadata and controls
38 lines (30 loc) · 1013 Bytes
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 'sinatra'
require 'sinatra/config_file'
require 'net/http'
require 'json'
require 'bundler'
require_relative 'middleware/validator'
ENV['RACK_ENV'] ||= 'development'
Bundler.require :default, ENV['RACK_ENV'].to_sym
class App < Sinatra::Base
use Validator
register Sinatra::ConfigFile
config_file "config/#{ENV["RACK_ENV"]}.yaml"
get '/cmd' do
slashText = params['text']
if slashText == 'status'
LoadBalanceController.command(settings)
elsif slashText != nil && slashText.start_with?('check')
ApiController.command(settings, slashText)
else
Rack::Response.new(
{ text: "Command not found - try: 'status' or 'check'"}
.to_json, 404, { 'Content-Type' => 'application/json' }).finish
end
end
get '*' do
Rack::Response.new(
{ message: "use /cmd [status/check]" }.to_json, 200,
{ 'Content-Type' => 'application/json' }).finish
end
end