Perhaps I'm being dense, but I'm struggling to find any description of how to handle this breaking behavior with a simple Plumber endpoint defined on a dynamic path. Here's the annotation-based definition:
#* @get /foo/<x>
#* @serializer text
function(x) {
str(x) ## log to the console for debugging/inspection purposes
x
}
Simple enough ... and works like a charm, a GET
to http://localhost/foo/bar
returns bar
, as expected.
But what happens if someone makes a request to that endpoint and decides to add a query parameter like so: http://localhost/foo/bar?x=baz
? Well, in that case:
-
baz
is returned -- which is incorrect from the perspective of the API designer, and - an abstraction has just been leaked to the caller (which could be considered a security flaw, as the API designer cannot necessarily control how a caller will probe that API).
Adding the endpoint annotation:
#* @preempt queryString
... solves the issue, but Plumber's default behavior is (i) to have that filter enabled and (ii) it's not immediately obvious (especially to any new programmer). To know to explicitly disable that filter requires inspecting the default router (or reading Plumber's source).
I cannot find any mention of this issue in the documentation; am I missing something re: guidance on how best to handle such scenarios?