Sha256: 2b08470c89a08fe71fa913c3bd6e6833f01d323d091e5ba401a5bcd2655a67e3

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

module QPush
  module Web
    class Server < Sinatra::Base
      set :public_folder, File.expand_path(File.dirname(__FILE__)) + '/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
      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[:count].to_i).to_json
      end

      get '/crons' do
        Get.crons(params[:start].to_i, params[:count].to_i)
      end

      get '/retries' do
        Get.retries(params[:start], params[:count])
      end

      get '/morgue' do
        Get.morgue(params[:start].to_i, params[:count].to_i)
      end

      post '/create' do
        Post.create(params)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qpush-0.1.10 lib/qpush/web/server.rb
qpush-0.1.8 lib/qpush/web/server.rb
qpush-0.1.7 lib/qpush/web/server.rb