Skip to contents

Create a router

Usage

router(
  ...,
  callback_pageload = NULL,
  callback_default = NULL,
  page_403 = router_page("403", ui_403),
  page_404 = router_page("404", ui_404)
)

Arguments

...

A set of router_page() objects. The first page is considered the default, and will be used if no path is provided.

callback_pageload

A function that is called immediately after each page is rendered. The function should take a router_page object and shiny session as input.

callback_default

A function that determines the default page. The function should take a shiny session as input and return the path of the default page. If not provided, the first page is used as the default.

page_403

A router_page to be used when a user attempts to access an unauthorised page.

page_404

A router_page to be used when a user attempts to access a page that doesn't exist.

Value

A router object.

Examples

if (interactive()) {

ui_test <- function(id) {
  htmltools::p("Test!")
}

home_page <- router_page("home", ui_test)
other_page - router_page("other", ui_test)

test_router <- router(home_page, other_page)
}