module Roda::RodaPlugins::HeaderMatchers::RequestMethods
Private Instance Methods
Source
# File lib/roda/plugins/header_matchers.rb, line 46 def match_accept(mimetype) if @env["HTTP_ACCEPT"].to_s.split(',').any?{|s| s.strip == mimetype} response[RodaResponseHeaders::CONTENT_TYPE] = mimetype end end
Match if the given mimetype is one of the accepted mimetypes.
Source
# File lib/roda/plugins/header_matchers.rb, line 53 def match_header(key) key = key.upcase key.tr!("-","_") unless key == "CONTENT_TYPE" || key == "CONTENT_LENGTH" key = "HTTP_#{key}" end if v = @env[key] @captures << v end end
Match if the given uppercase key is present inside the environment.
Source
# File lib/roda/plugins/header_matchers.rb, line 66 def match_host(hostname) if hostname.is_a?(Regexp) if match = hostname.match(host) @captures.concat(match.captures) end else hostname === host end end
Match if the host of the request is the same as the hostname. hostname
can be a regexp or a string.
Source
# File lib/roda/plugins/header_matchers.rb, line 78 def match_user_agent(pattern) if (user_agent = @env["HTTP_USER_AGENT"]) && (match = pattern.match(user_agent)) @captures.concat(match.captures) end end
Match the submitted user agent to the given pattern, capturing any regexp match groups.