Skip to content
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

Add details about named functions as router modifiers #824

Merged
merged 1 commit into from
Sep 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion vignettes/annotations.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pr() %>%

Annotation | Arguments | Description/References
-----------| --------- | ----------------------
`@plumber` | None | Modify plumber router from plumber file. The plumber router provided to the function **must** be returned.
`@plumber` | None | Modify plumber router from plumber file. The plumber router provided to the function **must** be returned. In most cases, anonymous functions are used following the `#* @plumber` annotation. However, named functions can also be used. When a named function is used, it must be referenced without parentheses.

##### Annotations example

Expand All @@ -228,6 +228,16 @@ function(pr) {
pr_set_debug(TRUE) %>%
pr_set_docs("swagger")
}

# Named function
debug_swagger <- function(pr) {
pr %>%
pr_set_debug(TRUE) %>%
pr_set_docs("swagger")
}

#* @plumber
debug_swagger
```

##### Equivalent programmatic usage
Expand Down