rstudio / plumber

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

Receiving 404 - Resource Not Found after rewriting req$PATH_INFO in filter #877

Open tonyfalc opened 2 years ago

tonyfalc commented 2 years ago

I have created a filter that parses req$postBody and rewrites req$PATH_INFO based on the value of one of its fields. For example, if I were to POST JSON containing

{ "tag" : "foo" }

to endpoint "/bar", at the conclusion of the filter, req$PATH_INFO is changed from "/bar" to "/foo/bar"; however, even though I have attached functions to both endpoints "/bar" and "/foo/bar" neither one of these is invoked: I simply receive a "404 - Resource Not Found." My understanding/expectation is that "plumber::forward()" would route the request based on the value of req$PATH_INFO, and the question was whether this routing was determined either before or after the filter was applied: if before, I would see the output of the function attached to "/bar" and if after, that associated with "/foo/bar." The fact that I get neither seems strange.

schloerke commented 1 year ago

I can see that req$PATH_INFO is being read after the filters is being executed. I don't readily see how the bug is occurring.

Can you please supply a reprex API? Thank you!


PR made so that mounted endpoints also listen to the latest value of req$PATH_INFO