lib/qpush/web/server.rb in qpush-0.1.2 vs lib/qpush/web/server.rb in qpush-0.1.4

- old
+ new

@@ -1,25 +1,54 @@ module QPush module Web class Server < Sinatra::Base + set :public_folder, Gem::Specification.find_by_name('qpush').gem_dir + '/lib/qpush/web/public' + before do + pass if request.path_info == '/' content_type :json + headers 'Access-Control-Allow-Origin' => '*', + 'Access-Control-Allow-Methods' => ['OPTIONS', 'GET', 'POST'] end + get '/' do + File.read(File.join(settings.public_folder, 'index.html')) + end + get '/stats' do - Get.stats.to_json + Get.stats end + get '/heartbeat' do + Get.heartbeat + end + + get '/history' do + Get.history + end + + get '/jobs' do + Get.jobs + end + + post '/queue_delayed' do + Post.queue_delayed(params[:id], params[:score]) + end + get '/delays' do - Get.delays(params[:start].to_i, params[:end].to_i).to_json + Get.delays(params[:start].to_i, params[:count].to_i).to_json end get '/crons' do - Get.crons(params[:start].to_i, params[:end].to_i).to_json + Get.crons(params[:start].to_i, params[:count].to_i) end - get '/fails' do - Get.fails(params[:start].to_i, params[:end].to_i).to_json + get '/retries' do + Get.retries(params[:start], params[:count]) + end + + get '/morgue' do + Get.morgue(params[:start].to_i, params[:count].to_i) end end end end