|
|
@@ -479,4 +479,22 @@ public class OpenAPIHandler {
|
|
|
).encode()))
|
|
|
.onFailure(th -> rc.fail(400, th));
|
|
|
}
|
|
|
+
|
|
|
+ public void unitsGET(RoutingContext rc) {
|
|
|
+ String host = hostURLFull(rc.request());
|
|
|
+
|
|
|
+ List<String> paramNavigationLinks = rc.queryParam("navigationLinks");
|
|
|
+ boolean navigationLinks = paramNavigationLinks.isEmpty() ? DEFAULT_NAVIGATION_LINKS : parseBoolean(paramNavigationLinks.get(0));
|
|
|
+
|
|
|
+ repo.allUnits()
|
|
|
+ .onSuccess(data -> rc.response().end(new JsonArray(
|
|
|
+ data.stream().map(u -> (navigationLinks ? JsonObject.of(
|
|
|
+ "Unit@NavigationLink", String.format("%s/units/%d", host, u.getUnitId())
|
|
|
+ ) : JsonObject.of()).mergeIn(JsonObject.of(
|
|
|
+ "id", u.getUnitId(),
|
|
|
+ "name", u.getName(),
|
|
|
+ "description", u.getDescription()
|
|
|
+ ))).collect(toList())).encode()))
|
|
|
+ .onFailure(th -> rc.fail(400, th));
|
|
|
+ }
|
|
|
}
|