private void deleteOne(RoutingContext routingContext) { Long id = getId(routingContext); if (id == null) { routingContext.response().setStatusCode(400).end(); } else { service.remove(id); } routingContext.response().setStatusCode(204).end(); }
private void addOne(RoutingContext routingContext) { FactorizationTask task = Json.decodeValue(routingContext.getBodyAsString(), FactorizationTask.class); task = service.create(task.getNumber()); routingContext .response() .setStatusCode(201) .putHeader("content-type", "application/json; charset=utf-8") .end(Json.encodePrettily(task)); }
private void getOne(RoutingContext routingContext) { Long id = getId(routingContext); if (id == null) { routingContext.response().setStatusCode(400).end(); } else { FactorizationTask task = service.getOne(id); if (task == null) { routingContext.response().setStatusCode(404).end(); } else { routingContext .response() .putHeader("content-type", "application/json; charset=utf-8") // TODO don't serialize null values .end(Json.encodePrettily(task)); } } }
private void getAll(RoutingContext routingContext) { routingContext .response() .putHeader("content-type", "application/json; charset=utf-8") .end(Json.encodePrettily(service.getAll())); }