From e42524ee8095ba245cef6fab2c0537ae799b73aa Mon Sep 17 00:00:00 2001 From: Bruno Tremblay Date: Thu, 16 Nov 2023 16:54:12 -0500 Subject: [PATCH 1/3] update parameters collision doc --- vignettes/routing-and-input.Rmd | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/vignettes/routing-and-input.Rmd b/vignettes/routing-and-input.Rmd index ffc588e93..12a51afbc 100644 --- a/vignettes/routing-and-input.Rmd +++ b/vignettes/routing-and-input.Rmd @@ -310,7 +310,21 @@ Alternatively, `echo {"id":123, "name": "Jennifer"} > call.json & curl --data @c As demonstrated above, the raw request body is made available as `req$bodyRaw` and parsed request body is available as `req$body`. -If multiple parameters are matched to the endpoint formals, an error will be thrown. Due to the nature of how multiple values can be matched to the same argument, it is recommended that `POST` endpoints have a function definition that only accepts the formals `req`, `res`, and `...`. If the endpoint arguments are to be processed like a list, they are available at `req$argsBody`, with all arguments at `req$args`. `req$args` is a combination of `list(req = req, res = res)`, `req$argsPath`, `req$argsBody`, and `req$argsQuery`. +#### Named parameters collision note + +Only the first matched formal arguments are passed automatically to the endpoint during execution. Duplicates are dropped. Query parameters have priority over path parameters, then finally, body parameters are matched last. + +While not required, it is recommended that endpoints have a function definition that only accepts the formals `req`, `res`, and `...` to avoid duplicates. If the endpoint arguments are to be processed like a list, they are available at `req$argsBody`, with all arguments at `req$args`. `req$args` is a combination of `list(req = req, res = res)`, `req$argsPath`, `req$argsBody`, and `req$argsQuery`. + +```{r, echo=FALSE, results='asis'} +function(req[, res, ...]) { + ... + req$argsQuery + req$argsPath + req$argsBody + ... +} +``` ### Cookies {#read-cookies} From ad7629940ea77a6b44f69878df4db4281f86bf9c Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Fri, 17 Nov 2023 10:39:45 -0500 Subject: [PATCH 2/3] Use `r` language for markdown --- vignettes/routing-and-input.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/routing-and-input.Rmd b/vignettes/routing-and-input.Rmd index 12a51afbc..8da133e00 100644 --- a/vignettes/routing-and-input.Rmd +++ b/vignettes/routing-and-input.Rmd @@ -316,7 +316,7 @@ Only the first matched formal arguments are passed automatically to the endpoint While not required, it is recommended that endpoints have a function definition that only accepts the formals `req`, `res`, and `...` to avoid duplicates. If the endpoint arguments are to be processed like a list, they are available at `req$argsBody`, with all arguments at `req$args`. `req$args` is a combination of `list(req = req, res = res)`, `req$argsPath`, `req$argsBody`, and `req$argsQuery`. -```{r, echo=FALSE, results='asis'} +``` r function(req[, res, ...]) { ... req$argsQuery From d510018e34f1b72bf9f67ff43bb33cfb2c3ba243 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Fri, 17 Nov 2023 10:45:52 -0500 Subject: [PATCH 3/3] Update Roxygen version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index ad6dfa433..3d6625a66 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -54,7 +54,7 @@ Suggests: redoc, rapidoc, sf -RoxygenNote: 7.2.2 +RoxygenNote: 7.2.3 Collate: 'async.R' 'content-types.R'