Sha256: 5a74203a50c429a9d78e31b894125f86c9994d1a06beb782b1bafb6483369a38

Contents?: true

Size: 919 Bytes

Versions: 1

Compression:

Stored size: 919 Bytes

Contents

module NginxTail
  module HttpMethod

    #
    # http://www.ietf.org/rfc/rfc2616.txt - "section 5.1.1 Method"
    #
    # OPTIONS GET HEAD POST PUT DELETE TRACE CONNECT
    #

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

        def self.to_http_method_s(http_method)
          (http_method ||= "").upcase!  # will be nil if $request == "-" (ie. "dodgy" HTTP requests)
          case http_method
          when "POST", "PUT", "DELETE"
            http_method.inverse # if Sickill::Rainbow.enabled...
          else
            http_method
          end
        end

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

      end
    end

    def to_http_method_s
      self.class.to_http_method_s(self.http_method)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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