Router | R Documentation |
Creates Router object.
paths
All added paths as is (with templates placeholders).
new()
Creates Router object.
Router$new()
size()
Returns number of paths added before.
Router$size()
Number of paths.
add_path()
Add path with their id.
Router$add_path(path, match = c("exact", "partial", "regex"), id)
path
Path to handle.
match
Defines how route will be processed. Allowed values:
exact
- match route as is. Returns 404 if route is not matched.
partial
- match route as prefix. Returns 404 if prefix are not matched.
regex
- match route as template. Returns 404 if template pattern not matched.
id
Path handler id.
match_path()
Find path within paths added before. Returns NULL
if path not matched.
Router$match_path(path, extract_vars = TRUE)
path
Path endpoint.
extract_vars
Extart path parameters (when handler matches regex).
Handler id.
clone()
The objects of this class are cloneable with this method.
Router$clone(deep = FALSE)
deep
Whether to make a deep clone.
r = RestRserve:::Router$new()
r$add_path("/test", "exact", "testid")
r$add_path("/area", "partial", "areaid")
r$add_path("/template/{variable}", "regex", "templateid")
r$match_path("/test") # testid
r$match_path("/area/entry") # areaid
r$match_path("/template/12345") # templateid
attr(r$match_path("/template/12345"), "parameters_path") # variables values
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.