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["Content-Type"] = mimetype
  end
end

def match_header(key)

Match if the given uppercase key is present inside the environment.
def match_header(key)
  if v = @env[key.upcase.tr("-","_")]
    if roda_class.opts[:match_header_yield]
      @captures << v
    else
      RodaPlugins.deprecate("The :header hash matcher will yield the header value in Roda 2.  To turn on the Roda 2 behavior, set opts[:match_header_yield] to true for your Roda class.")
    end
  end
  v
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)
  hostname === host
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