Skip to contents

Enhanced HTTP methods support for multiple endpoints

Usage

payload_methods(base_ui, endpoints)

Arguments

base_ui

The original UI (tagList, fluidPage, or a function(req) returning UI)

endpoints

A list of endpoint configurations. Each element should be a list with: path, methods (character vector), and optionally token

Value

A function that takes a request object and returns either the regular UI (for GET requests) or an HTTP response (for other HTTP methods). This function should be passed to shinyApp() as the ui parameter.

Examples

if (interactive()) {
  endpoints <- list(
    list(path = "/api/data", methods = c("POST", "PUT"), token = "secret"),
    list(path = "/api/delete", methods = "DELETE", token = "admin-token"),
    list(path = "/webhooks", methods = c("POST", "PATCH"))
  )
  ui <- payload_methods(fluidPage(h1("My App")), endpoints)
  shinyApp(ui, server, uiPattern = ".*")
}