code: function handleChat(request, response, chat) {
      var resp, id;
      if (request.method === "POST") {
          // add a line to the chat log
          requestBody(request, function(form) {
              while (chat.length > CHATLINES) {
                  chat.shift();
              }
  
              /* If data is present in the chat, then increment the last id,
               * otherwise start at 0.
               */
              if (chat.length) {
                  id = chat[chat.length-1].id + 1;
              } else {
                  id = 0;
              }
              chat.push({
                  id: id,  // chat line id
                  name: form.name,  // the user's name
                  input: form.input  // the user's text input
              });
              respOk(response, '', 'text/json');
          });
      } else {
          /* Return chat data. If lastid is specified, then we only return
           * chat lines since this id.
           */
          var form = requestQuery(request);
          var lastid = +form.lastid;
          if (lastid >= 0) {
              for (var i=0; i<chat.length; i++) {
                  if (chat[i].id === lastid) {
                      break;
                  }
              }
              resp = JSON.stringify(chat.slice(i+1));
          } else {
              resp = JSON.stringify(chat);
          }
          respOk(response, resp, 'text/json');
      }
  }
docs: Handle transaction on chat.
  @param chat {list}: a chat object, which is a list of
  {id: {number}, name: {string}, input: {string}} objects