rstudio / plumber

Turn your R code into a web API.
https://www.rplumber.io
Other
1.39k stars 255 forks source link

Support mounting using `pr_mount()` without a trailing slash #952

Open gacolitti opened 5 months ago

gacolitti commented 5 months ago

I want to be able to mount routers without a trailing slash. As far as I can tell, this is not supported.

Here is an example:

library(plumber)
pr1 <- pr_get(pr(), "/", function() {})

pr() |> 
  pr_mount("/api/test", pr1) |> 
  pr_run(port = 8322)

I want the endpoint to be /api/test, but instead it becomes /api/test/ and I'm not sure how to remove the trailing slash.

I tried doing:

pr1 <- pr_get(pr(), "", function() {})

but that returns the same endpoint as before.

Maybe there can be an additional argument to pr_mount() to control this behavior:

pr_mount(ignore_trailing_slashes = TRUE)