Spark WS Framework filter called twice

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:

// Add filter to all requests which adds a trailing slash if it is missing //
before("*", Filters.addTrailingSlashes);
path("/api", () -> {
    // Authentication Intercept //
    before("/*", AuthenticationIntercept.authenticationIntercept);

    // Sampling Endpoints //
    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.

.

,

+6
1

, . , , - favicon.ico (/favicon.ico), .

- , , , , , .

, , , , - :

http://yourdomain.com/aaa/bbb

. , - favicon.ico.

http, Fiddler , , .

. , , . , .

+2

All Articles