Possible to mount multiple files to the same route?

Hi,

Im looking to separate out my complex API structure so that I have the following structure. I am wondering. Is there a way to mount all files under the users/ folder to the same ./api/v1/users route? And the same for projects/ ? This becomes a bigger problem when I have dynamic paths under one of these as well.

In shiny, to accomplish something like this Id use source('file.R', local=TRUE) but in this case plumber must source the mounted files differently.

The reason I am structuring it this way is to reduce complexity during development (as opposed to adding multiple verbs to the same endpoint).

+-- v1/
|+-- users/
|+----- GET.R
|+----- POST.R
|+-- projects/
|+----- GET.R
|+----- POST.R


Referred here by rstudio/plumber

library(plumber)
pr_users <- plumb(dir = "./users")
pr_projects <- plumb(dir = "./projects")
pr <- pr() %>%
  pr_mount("/users", pr_users) %>%
  pr_mount("/projects", pr_projects)
1 Like

Thanks Meztez, its helpful to know the plumb takes a directory but unfortunately this doesnt work since it expects to find a plumber.R file there. Is there a way to still manage with the separate R files in those directories? Im looking at entrypoints but not sure if I understand the applicability here.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.