I have defined a route with two endpoints (randLetters and ping). I then defined two filters (validation and add session ID). I then want the ping endpoint to opt out of the filter validation, but not the session ID filter, so I added a preeempt tag. However, it looks like the order filters are defined matters: the code as provided works as expected, but if I swap around the two filters and I define the validation filter before the session ID one, then ping opts out of both filters.
Anyone knows what is going on? Is it expected that the order of filers declaration matters? Is there some wrong with my code?
library(plumber)
pr() %>%
# filters
pr_filter('lettersSessionID', function(req){
print('filter add session ID')
forward()
}) %>%
pr_filter('lettersValidation', function(req){
print('filter validation')
forward()
}) %>%
# endpoints
pr_get(path = '/randLetters',
handler = function(n = 10){sample(letters, n, replace = TRUE)},
serializer = serializer_json()) %>%
pr_get(path = '/ping',
preempt = 'lettersValidation',
handler = function(){},
serializer = serializer_json()) %>%
pr_run()