module Roda::RodaPlugins::HeaderMatchers::RequestMethods
def match_accept(mimetype)
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)
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)
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)
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