I am trying to access URI params in filters and I'm getting zero sized map when calling Request.params(). The params() method works as expected in the route itself but not in before and after filters.
@Override
public void handle(Request req, Response res) {
if (req.uri().contains("/publish")) {
if (NOTIFICATION.equals(req.params(":type").toLowerCase())) {
Message m = JsonIterator.deserialize(req.body(), Message.class);
req.attribute(PUBLISH_BODY, m);
if (m == null || m.getN() == null)
Spark.halt(HttpStatus.SC_BAD_REQUEST);
}
}
}
In the above example req.params(":type") returns null and req.params() is an empty map
I am trying to access URI params in filters and I'm getting zero sized map when calling Request.params(). The params() method works as expected in the route itself but not in before and after filters.
In the above example
req.params(":type")
returns null andreq.params()
is an empty map