module Sinatra::ServantConfig
Public Class Methods
registered(app)
click to toggle source
# File lib/belphanior/servant/servant_config.rb, line 28 def self.registered(app) app.set :servant_config_file, ServantConfigHelper::DEFAULT_CONFIG_PATH app.set :servant_config_db, ServantConfigDb.new( <<EOF { "ip":"127.0.0.1", "port": "80" } EOF ) app.get '/config' do BelphaniorServantHelper.text_out_as_json(settings.servant_config_db.to_json) end app.get '/config/:name' do [200, settings.servant_config_db.get(params[:name])] end app.post '/config/:name' do old_value = settings.servant_config_db.get(params[:name]) begin settings.servant_config_db.set(params[:name], request.body.read) ServantConfigHelper.write_config_file( settings.servant_config_file, settings.servant_config_db) return [200, old_value] rescue ServantConfigException => e return [500, "Could not write config: #{e}"] end end end
Public Instance Methods
load_servant_config()
click to toggle source
# File lib/belphanior/servant/servant_config.rb, line 59 def load_servant_config set(:servant_config_db, ServantConfigHelper.prepare_config_file( servant_config_file, servant_config_db)) end
servant_config()
click to toggle source
# File lib/belphanior/servant/servant_config.rb, line 63 def servant_config servant_config_db end