Skip to contents

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&param2=text, ?param1=1&param2=text is the query string, param1 and param2 are keys, and 1 and text are their corresponding values.

Usage

req_has_query(key, values = NULL, negate = FALSE)

Arguments

key

The key that must be present, as a length-1 character vector.

values

Details about what to look for in the key. NULL indicates that the key must be present but its contents are unimportant for this action. Otherwise the actual value of the query must be present in values.

negate

If TRUE, trigger the corresponding scene when this action is not matched.

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"