Currently if we halt with a custom body we dont have any way to transform the response unless calling explicitly a transformation:
We have to do Spark.halt(HttpStatus.SC_BAD_REQUEST, responseTransformer.transform(message)); on each halt call
Could we have a feature like:
Spark.onErrorApply(responseTransformer); // Or a better name for the method
that applies to all exception messages?
Or at least be able to subscribe to events and tune it for all of the halts, like we can do with 404 or 500 or any particular exception except HaltException:
Spark.notFound(...); // Gets called
Spark.internalServerError(...); // Gets called
Spark.exception(HaltException.class, (ex, req, res) -> { // Wont get called
res.status(ex.statusCode());
res.body(responseTransformer.transform(ex.body()));
});
Currently if we halt with a custom body we dont have any way to transform the response unless calling explicitly a transformation:
We have to do
Spark.halt(HttpStatus.SC_BAD_REQUEST, responseTransformer.transform(message));
on each halt callCould we have a feature like:
that applies to all exception messages?
Or at least be able to subscribe to events and tune it for all of the halts, like we can do with 404 or 500 or any particular exception except HaltException: