Method: Puma::DSL#supported_http_methods

Defined in:
lib/puma/dsl.rb

#supported_http_methods(methods) ⇒ Object

Note:

If the methods value is :any, no method check with be performed, similar to Puma v5 and earlier.

Supported http methods, which will replace Puma::Const::SUPPORTED_HTTP_METHODS. The value of :any will allows all methods, otherwise, the value must be an array of strings. Note that methods are all uppercase.

Puma::Const::SUPPORTED_HTTP_METHODS is conservative, if you want a complete set of methods, the methods defined by the [IANA Method Registry](www.iana.org/assignments/http-methods/http-methods.xhtml) are pre-defined as the constant Puma::Const::IANA_HTTP_METHODS.

Examples:

Adds ‘PROPFIND’ to existing supported methods

supported_http_methods(Puma::Const::SUPPORTED_HTTP_METHODS + ['PROPFIND'])

Restricts methods to the array elements

supported_http_methods %w[HEAD GET POST PUT DELETE OPTIONS PROPFIND]

Restricts methods to the methods in the IANA Registry

supported_http_methods Puma::Const::IANA_HTTP_METHODS

Allows any method

supported_http_methods :any


1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
# File 'lib/puma/dsl.rb', line 1437

def supported_http_methods(methods)
  if methods == :any
    @options[:supported_http_methods] = :any
  elsif Array === methods && methods == (ary = methods.grep(String).uniq) &&
    !ary.empty?
    @options[:supported_http_methods] = ary
  else
    raise "supported_http_methods must be ':any' or a unique array of strings"
  end
end