I wonder how I can include a plumber API defintion inside my package so that the plumber endpoints can directly use the functionality provided by the package itself. During my research, I found this repo plumbpkg/manifest.json at main · sol-eng/plumbpkg · GitHub
At first glance it looked like it was exactly what I was looking for, but a closer look revealed the following problem. First of all, I'm using the full Posit framework, that is, workbench, package manager and connect server. This leads to my problem: In the above link, the package itself is registered inside the manifest.json file, i.e. plumbpkg. This is required as inside the api endpoints, the author uses the namespace plumbpkg:: in order to access the files/functions. However, this introduces a self-references which I don't like. This would mean that I need that before I can test changes I need to upload a new version of the package plumbpkg to the package manager, use rsconnect::writeManifest() to register this new version in the manifest and then upload the new package version to the Connect server.
I know that there is a package called pkgload::load_all() which would load all the functions inside the current package. However, I experienced several naming clashes with my reference classes when using this method, so this is no option for me.
What is the common or recommended way of including a plumber defintion inside a package?
thanks! Although this might be of interest at antoher point, the link does not cover my issue, as the plumber api itself does not contain any package functionality
To include a Plumber API definition inside your package without self-referencing issues, avoid hard-coding the package name in the manifest. Instead, use pkgload::load_all() for local development, but to prevent naming clashes, consider defining endpoints directly within the package using Plumber$new() and referencing functions without explicit namespace calls. For a reliable
setup, streamline testing and deployment by handling endpoint registration dynamically within the package.