View source: R/brochure-fns-routr.R
| page | R Documentation |
A page is an url, a UI and a server function. Opening it starts a Shiny session of its own, separate from any other page of the app.
page(
href,
ui = tagList(),
server = function(input, output, session) {
},
method = "GET",
req_handlers = list(),
res_handlers = list()
)
href |
The endpoint to serve the UI on. It can carry parameters, as in
|
ui |
The UI definition of the app (for example, a call to
If bookmarking is enabled (see |
server |
A function with three parameters: |
method |
The HTTP method the page answers to. Defaults to |
req_handlers |
a list of functions that can manipulate the |
res_handlers |
A list of functions that can manipulate the httpResponse
object before it is send to the browser. Each function must take a |
Requests are matched against hrefs by the routr package, so an href is written the way routr writes a path:
"/contact" matches that path and nothing else.
":name" matches exactly one segment and captures it, so "/who/:id"
matches /who/colin but neither /who nor /who/colin/edit. Use several
of them if you need to: "/pair/:a/:b".
"*" matches whatever is left, so "/files/*" matches /files/a/b/c.
The captured value is named *1.
A trailing slash never matters: /contact and /contact/ are the same page.
Pages are tried in the order you passed them to brochureApp(), and the
first match wins. That holds for the session a page opens as well, which is
resolved on the path alone: the websocket handshake is a GET whatever
method the page answers on, so two pages sharing an href run the server of
the first one declared, whichever of them was served. That matters when two hrefs can match the same url:
declared as page("/who/me") then page("/who/:id"), a request for
/who/me gets the first; declared the other way round, the parameterised
page catches it and the static one is never reached. Put the specific ones
first.
See the routr documentation at https://routr.data-imaginist.com/ for the full path syntax.
A brochure_page object, to be passed to brochureApp().
get_keys() to read the parameters of an href, and
vignette("handlers") for req_handlers and res_handlers.
library(shiny)
page(
href = "/page2",
ui = tagList(
h1("This is my second page"),
plotOutput("plotb")
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.