Sha256: eabd4ad7406a3c77ae807fb2af0e126862e94f201c9c6a69ebf1f96aaf28965f

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

require 'pathname'

module Partiarelic
  class App
    def initialize(path: nil)
      @path = path
    end

    ACCEPT_METHODS = ['GET', 'HEAD'].freeze

    def call(env)
      unless ACCEPT_METHODS.include?(env['REQUEST_METHOD']) && (@path ? env['PATH_INFO'] == @path : true)
        return [404, {'Content-Type' => 'text/plain'}, []]
      end

      NewRelic::Agent.manual_start

      headers = {'Content-Type' => 'text/plain'}
      if env['REQUEST_METHOD'] == 'HEAD'
        [200, headers, []]
      else
        [200, headers, [Socket.gethostname]]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
partiarelic-0.1.0 lib/partiarelic/app.rb