SHARE
TWEET

Untitled

a guest Mar 18th, 2016 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.      * @param routingContext
  3.      * <p>
  4.      * Responsible for retrieving all todos from the list and send as encoded json to user
  5.      * </p>
  6.      */
  7.     private void getAllTodos(RoutingContext routingContext) {
  8.  
  9.         Map<Integer, String> todos = new HashMap<Integer, String>();
  10.  
  11.         JsonArray keys = awaitResult(r -> client.keys("*", r));
  12.  
  13.         for (Object k : keys) {
  14.             String key = (String) k;
  15.             String todomessage = awaitResult(h -> client.get(key, h));
  16.             todos.put(Integer.parseInt(key), todomessage);
  17.         }
  18.  
  19.         // Write the HTTP response
  20.         // The response is in JSON using the utf-8 encoding
  21.         // will return map of
  22.         routingContext.response().putHeader("content-type", "application/json; charset=utf-8")
  23.                 .end(Json.encodePrettily(todos.values()));
  24.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top