Module: Elasticshell::RecognizesVerb

Included in:
Commands::Request, Commands::Request::Parser, Commands::SetVerb, Commands::SetVerb
Defined in:
lib/elasticshell/utils/recognizes_verb.rb

Constant Summary collapse

VERB_RE =
"(?:HEAD|GET|PUT|POST|DELETE)"

Instance Method Summary collapse

Instance Method Details

#canonicalize_verb(v) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/elasticshell/utils/recognizes_verb.rb', line 10

def canonicalize_verb v
  case v.to_s
  when /^G/i  then "GET"
  when /^PO/i then "POST"
  when /^PU/i then "PUT"
  when /^D/i  then "DELETE"
  when /^H/i  then "HEAD"
  end
end

#is_http_verb?(s) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/elasticshell/utils/recognizes_verb.rb', line 20

def is_http_verb? s
  s =~ Regexp.new("^" + verb_re + "$", true)
end

#verb_reObject



6
7
8
# File 'lib/elasticshell/utils/recognizes_verb.rb', line 6

def verb_re
  RecognizesVerb::VERB_RE
end