Create a scene_action specifying a key that must be
present (or absent) in the query string (the part of the URL when the shiny
app was called, after "?"), and optionally a value or values for that key.
For example, in myapps.shinyapps.io/myapp?param1=1¶m2=text,
?param1=1¶m2=text is the query string, param1 and param2 are keys,
and 1 and text are their corresponding values.
Arguments
- key
The key that must be present, as a length-1 character vector.
- values
Details about what to look for in the
key.NULLindicates that thekeymust be present but its contents are unimportant for this action. Otherwise the actual value of the query must be present invalues.- negate
If
TRUE, trigger the corresponding scene when this action isnotmatched.
Value
A scene_action, to be used in set_scene().
Examples
# Specify an action to detect a "code" parameter in the query.
req_has_query("code")
#> $check_fn
#> <partialised>
#> function (...)
#> ~.fn(key = ~key, values = ~values, ...)
#> <environment: 0x55fc8ec0c5d0>
#>
#> $methods
#> [1] "GET"
#>
#> attr(,"class")
#> [1] "scene_action" "list"
# Specify an action to detect the *lack* of a "code" parameter in the query.
req_has_query("code", negate = TRUE)
#> $check_fn
#> function (...)
#> !f(...)
#> <bytecode: 0x55fc8fbdbcc0>
#> <environment: 0x55fc8ecc2468>
#>
#> $methods
#> [1] "GET"
#>
#> attr(,"class")
#> [1] "scene_action" "list"
# Specify an action to detect a "language" parameter, with values containing
# "en" or "es".
req_has_query("language", "en|es")
#> $check_fn
#> <partialised>
#> function (...)
#> ~.fn(key = ~key, values = ~values, ...)
#> <environment: 0x55fc8ed2d768>
#>
#> $methods
#> [1] "GET"
#>
#> attr(,"class")
#> [1] "scene_action" "list"