Sha256: 08b86d0fe1c82365ee74a8d9db41017b687928cc0dc1b03fbae506bf8e81f883

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

# sensu routes
module Sabisu
  # server class
  class Server
    def sensu(request)
      sensu = Sensu.new
      tmp_path = request.path_info.split('/')
      tmp_path.delete_at(1)
      path = tmp_path.join('/')
      opts = {
        path: path,
        method: request.request_method,
        ssl: API_SSL
      }
      begin
        opts[:payload] = JSON.parse(request.body.read) if request.post?
      rescue StandardError
        puts "unable to parse: #{request.body.read}"
      end
      sensu.request(opts)
    end

    route :get, :post, '/sensu/stashes' do
      res = sensu(request)
      status res.code
      headers 'content-type' => 'application/json'
      body res.body
    end

    delete '/sensu/stashes/*' do
      res = sensu(request)
      status res.code
      headers 'content-type' => 'application/json'
      body res.body
    end

    post '/sensu/resolve' do
      res = sensu(request)
      status res.code
      headers 'content-type' => 'application/json'
      body res.body
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sabisu-0.1.3 lib/sabisu/routes/sensu.rb
sabisu-0.1.2 lib/sabisu/routes/sensu.rb
sabisu-0.1.1 lib/sabisu/routes/sensu.rb
sabisu-0.1.0 lib/sabisu/routes/sensu.rb