Sha256: 35ca772fb88b20b56d0b7b0f16f54cd13fb016027e04b2046b3ec0f48ecb7745

Contents?: true

Size: 810 Bytes

Versions: 1

Compression:

Stored size: 810 Bytes

Contents

module NginxTail
  module Request

    UNKNOWN_REQUEST = "-".freeze # the 'default' nginx value for $request variable

    def self.included(base) # :nodoc:
      base.class_eval do

        def self.unknown_request?(request)
          request == UNKNOWN_REQUEST
        end

        # this ensures the below module methods actually make sense...
        raise "Class #{base.name} should implement instance method 'request'" unless base.instance_methods.map(&:to_s).include? 'request'

      end
    end

    def unknown_request?
      self.class.unknown_request?(self.request)
    end

    def to_request_s
      if self.unknown_request?
        self.request
      else
        # note: we exclude the HTTP version info...
        "%s %s" % [self.to_http_method_s, self.to_uri_s]
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ntail-1.3.2 lib/ntail/request.rb