Return 404s automatically when our response is null
This commit is contained in:
parent
df938dcd0a
commit
5805506372
@ -425,8 +425,14 @@ public final class APIv3 extends AbstractVerticle {
|
|||||||
|
|
||||||
public static void respondJson(RoutingContext ctx, int code, Object response) {
|
public static void respondJson(RoutingContext ctx, int code, Object response) {
|
||||||
ctx.response().putHeader(HttpHeaders.CONTENT_TYPE, MediaType.JSON_UTF_8.toString());
|
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().setStatusCode(code);
|
||||||
ctx.response().end(gson.toJson(response));
|
ctx.response().end(gson.toJson(response));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user