Module: Sinatra::IntegratorUtils
- Defined in:
- lib/integrator_utils.rb
Defined Under Namespace
Modules: Helpers
Class Method Summary collapse
Class Method Details
.registered(app) ⇒ Object
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 |
# File 'lib/integrator_utils.rb', line 26 def self.registered(app) app.helpers Sinatra::JSON app.helpers IntegratorUtils::Helpers app.set :public_folder, './public' app.before do if request.get? && request.path_info == '/' redirect '/endpoint.json' else halt 401 if request.env["HTTP_X_AUGURY_TOKEN"] != ENV['ENDPOINT_KEY'] end if request.post? begin = ::JSON.parse(request.body.read).with_indifferent_access @config = config() rescue Exception => e halt 406 end end end app.get '/auth' do status 200 end end |