Sha256: 657525f40139dc3b879d74049355f770c15a4077523b9cbdbf7f9c4543896bbf

Contents?: true

Size: 608 Bytes

Versions: 2

Compression:

Stored size: 608 Bytes

Contents

require 'pathname'
require 'newrelic_rpm'

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

2 entries across 2 versions & 1 rubygems

Version Path
partiarelic-0.1.2 lib/partiarelic/app.rb
partiarelic-0.1.1 lib/partiarelic/app.rb