Skip to contents

method matcher

Details

Matches regardless of case. e.g., POST will match to post

Public fields

pattern

(character) an http method

Methods


Method new()

Create a new MethodPattern object

Usage

MethodPattern$new(pattern)

Arguments

pattern

(character) a HTTP method, lowercase

Returns

A new MethodPattern object


Method matches()

test if the pattern matches a given http method

Usage

MethodPattern$matches(method)

Arguments

method

(character) a HTTP method, lowercase

Returns

a boolean


Method to_s()

Print pattern for easy human consumption

Usage

MethodPattern$to_s()

Returns

a string


Method clone()

The objects of this class are cloneable with this method.

Usage

MethodPattern$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

(x <- MethodPattern$new(pattern = "post"))
#> <MethodPattern>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     initialize: function (pattern) 
#>     matches: function (method) 
#>     pattern: post
#>     to_s: function () 
x$pattern
#> [1] "post"
x$matches(method = "post")
#> [1] TRUE
x$matches(method = "POST")
#> [1] TRUE

# all matches() calls should be TRUE
(x <- MethodPattern$new(pattern = "any"))
#> <MethodPattern>
#>   Public:
#>     clone: function (deep = FALSE) 
#>     initialize: function (pattern) 
#>     matches: function (method) 
#>     pattern: any
#>     to_s: function () 
x$pattern
#> [1] "any"
x$matches(method = "post")
#> [1] TRUE
x$matches(method = "GET")
#> [1] TRUE
x$matches(method = "HEAD")
#> [1] TRUE