-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tidy plumber API #590
Tidy plumber API #590
Conversation
Co-authored-by: Barret Schloerke <barret@rstudio.com>
|
Final concern is over Ideas for a different name...
|
I like |
Talked with @blairj09 . |
Rename pr_set_ functions to be more consistent
…tudio#585 for serializer_content_type
@blairj09 Can we also add: pr_cookie <- function(
pr,
key,
name = "plumber",
expiration = FALSE,
http = TRUE,
secure = FALSE
) {
pr$registerHooks(
sessionCookie(key = key, name = name, expiration = expiration, http = http, secure = secure)
)
invisible(pr)
} The tests look great! |
Have another addition (via @trestletech) from https://www.rplumber.io/articles/security.html#cross-origin-resource-sharing-cors This one is also a similar situation to (** Update) #' @filter cors
cors <- function(req, res) {
res$setHeader("Access-Control-Allow-Origin", "*")
if (req$REQUEST_METHOD == "OPTIONS") {
res$setHeader("Access-Control-Allow-Methods","*")
res$setHeader("Access-Control-Allow-Headers", req$HTTP_ACCESS_CONTROL_REQUEST_HEADERS)
res$status <- 200
return(list())
} else {
plumber::forward()
}
} into pr_cors <- function(pr, origin, name = "cors") {
pr_filter(pr, name, function(req, res) {
res$setHeader("Access-Control-Allow-Origin", origin)
forward()
})
}
pr_options <- function(pr, methods = "*", name = "options") {
pr_filter(pr, name, function(req) {
if (req$REQUEST_METHOD == "OPTIONS") {
res$setHeader("Access-Control-Allow-Methods","*")
res$setHeader("Access-Control-Allow-Headers", req$HTTP_ACCESS_CONTROL_REQUEST_HEADERS)
res$status <- 200
return(list())
}
plumber::forward()
})
} |
- Standardize capitalization - Add checks for pr object - Minor documentation updates - POST_BODY -> postBody
…ntent type serializer
First pass at a "tidy" API for the R6 methods used by plumber. Tests still need to be added, but wanted to get this initial approach out there.
PR task list:
devtools::document()