
Wrap an existing UI with an integrated POST handler on the same port
Source:R/payload.R
payload_ui.RdWrap an existing UI with an integrated POST handler on the same port
Arguments
- base_ui
The original UI (tagList, fluidPage, or a function(req) returning UI)
- path
The URL path to handle POST requests (default "/ingress")
- token
Optional authentication token for POST requests
- response_handler
Optional function to customize responses. Should accept (payload, req) and return a list with: status, body, content_type, headers (all optional)
Value
A function that takes a request object and returns either the regular UI (for GET requests) or an HTTP response (for POST requests). This function should be passed to shinyApp() as the ui parameter.
Examples
if (interactive()) {
ui <- payload_ui(
fluidPage(h1("My App")),
path = "/data",
token = "secret123"
)
shinyApp(ui, server, uiPattern = ".*")
# With custom response handler
ui <- payload_ui(
fluidPage(h1("My App")),
path = "/api/process",
response_handler = function(payload, req) {
list(
status = 201L,
body = list(received = TRUE, id = sample(10000:99999, 1))
)
}
)
}