This is the code for an app
# load_libraries ----------------------------
library("RestRserve")
# func_UserId ----------------------------
get_userid <- function(req, res) {
id = req$get_param_path("id")
res$set_body(id)
}
# create app --------------------------------
app = Application$new()
# define Routes -----------------------------
### /user/:id main Route
app$add_get(
path = "/user/{id}",
FUN = get_userid,
match = "exact"
)
# Run App -----------------------------------
backend = BackendRserve$new()
backend$start(app, http_port = 9000)
and I am not able to extract the ID from the route. I read the documentation but it's still not clear enough. Please let me know if you have any answer for it.
Thanks in advance
library(RestRserve)
app = Application$new()
app$add_get("/user/{id}", function(req, res) {
str(req$parameters_path)
}, match = "regex")
req = Request$new("/user/100500", method = "GET")
res = app$process_request(req)
#List of 1
# $ id: chr "100500"