0
votes

Am looking for an example of a Vert.x response handler that, for example, can add a header for all 500 responses.

All handlers seem to be handling only requests.

1

1 Answers

0
votes

This is what I ended up using.

router.route().handler(ctx -> {
    ctx.addHeadersEndHandler(ctx1 -> {
        if (ctx.response().getStatusCode() >= 500) {
            log.error("Failure: " + ctx.request().absoluteURI() + " --> " + ctx.response().getStatusCode());
        }
    });
    ctx.next();
});