I am attached to using the before filter to add trailing slashes, as well as before the filter to handle authentication at a specific endpoint.
Here is my routing code:
before("*", Filters.addTrailingSlashes);
path("/api", () -> {
before("/*", AuthenticationIntercept.authenticationIntercept);
get(Path.Web.SAMPLES_FETCH_LATEST, SamplingController.fetchLatestSamples, new JsonTransformer());
get(Path.Web.SAMPLES_FETCH_FOR_DEVICE, SamplingController.getLatestSamplesForDevice, new JsonTransformer());
});
Then I hit the following endpoint:
local: 4567 / API / samples / 10
It happens that addTrailingSlashes is first called. Then the authentication filter is called, then addTrailingSlashes is again called using localhost: 4567 / api / samples / 10 / as the endpoint of the request, and finally the authentication filter is called again.
Is this the expected behavior? I want the called addTrailingSlashes to add a slash once and then forward the request once so that the authentication filter is called only once.
.
,