Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param routingContext
- * <p>
- * Responsible for retrieving all todos from the list and send as encoded json to user
- * </p>
- */
- private void getAllTodos(RoutingContext routingContext) {
- Map<Integer, String> todos = new HashMap<Integer, String>();
- JsonArray keys = awaitResult(r -> client.keys("*", r));
- for (Object k : keys) {
- String key = (String) k;
- String todomessage = awaitResult(h -> client.get(key, h));
- todos.put(Integer.parseInt(key), todomessage);
- }
- // Write the HTTP response
- // The response is in JSON using the utf-8 encoding
- // will return map of
- routingContext.response().putHeader("content-type", "application/json; charset=utf-8")
- .end(Json.encodePrettily(todos.values()));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement