Return 404s automatically when our response is null

This commit is contained in:
Colin McDonald 2016-07-25 16:57:44 -04:00
parent df938dcd0a
commit 5805506372
1 changed files with 8 additions and 2 deletions

View File

@ -425,8 +425,14 @@ public final class APIv3 extends AbstractVerticle {
public static void respondJson(RoutingContext ctx, int code, Object response) {
ctx.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.JSON_UTF_8.toString());
if (response == null) {
ctx.response().setStatusCode(404);
ctx.response().end("{}");
} else {
ctx.response().setStatusCode(code);
ctx.response().end(gson.toJson(response));
}
}
}