Consider the following snippet:
Javalin app = Javalin.create().defaultContentType("application/json").start();
app.get("/", ctx -> { throw new ForbiddenResponse(); });
The defaultContentType is sent to the client, but the answer is in text/plain.
Is this intended? If not, I would consider a little fix to io.javalin.core.util.HttpResponseExceptionMapper in the method handleException change
if (ctx.header(Header.ACCEPT)?.contains("application/json") == true) to something like
if (ctx.header(Header.ACCEPT)?.contains("application/json") || ctx.res.contentType.equals("application/json"))
Thanks for the issue. I'm currently traveling, but I'll have a look when I get back.
@maxemann96 thanks, looks like you've found a bug. Would you like to submit a PR to fix it?
Oh, ok this was very quick, thx for your time :)
@maxemann96 thank @Playacem, he fixed it :)
So, @Playacem thx :)
Most helpful comment
So, @Playacem thx :)