module Roda::RodaPlugins::HeaderMatchers::RequestMethods

def match_accept(mimetype)

Match if the given mimetype is one of the accepted mimetypes.
def match_accept(mimetype)
  if @env["HTTP_ACCEPT"].to_s.split(',').any?{|s| s.strip == mimetype}
    response[RodaResponseHeaders::CONTENT_TYPE] = mimetype
  end
end

def match_header(key)

Match if the given uppercase key is present inside the environment.
def match_header(key)
  key = key.upcase.tr("-","_")
  unless key == "CONTENT_TYPE" || key == "CONTENT_LENGTH"
    key = "HTTP_#{key}"
  end
  if v = @env[key]
    @captures << v
  end
end

def match_host(hostname)

can be a regexp or a string.
Match if the host of the request is the same as the hostname. +hostname+
def match_host(hostname)
  if hostname.is_a?(Regexp)
    if match = hostname.match(host)
      @captures.concat(match.captures)
    end
  else
    hostname === host
  end
end

def match_user_agent(pattern)

regexp match groups.
Match the submitted user agent to the given pattern, capturing any
def match_user_agent(pattern)
  if (user_agent = @env["HTTP_USER_AGENT"]) && user_agent.to_s =~ pattern
    @captures.concat($~[1..-1])
  end
end