I'm trying to make a filter that matches the following URL's:
/foo
and /foo/*
So anything under /foo/
and also the base case /foo
I have this filter:
Spark.before("/foo/*", (request, response) -> {
String ticket = request.cookie("session");
if (ticket == null) {
Spark.halt(302);
}
});
But of course this does not execute when I enter to /foo
I tried with the following but with no luck:
/foo*
/foo.*
/foo/
Is there anyway to achieve this? Or maybe to use a list of URL? so that I can assign both url to the same filter.
And please don't say to store the function in a variable so that the I use it two times because I think that is not clean at all..