anchor.diff:  -export([handle/2]).
   -export([terminate/3]).
   
  --record(st, {dbname, changes, last_seq, mode}).
  +-record(st, {dbname, changes, last_seq, mode, subscribed}).
   
   init(_Type, Req, []) ->
       {Feed, Req2} = cowboy_req:qs_val(<<"feed">>, Req, <<"normal">>),
  
positive.code:     case Changes of
          [] ->
              ok = subscribe(DbId),
              info(db_updated, Req, State);
          _ ->
              {ok, Req, State}
      end;
  
negative.code:     Headers = [{<<"content-type">>, <<"text/event-stream">>}],
      {ok, Req2} = cowboy_req:chunked_reply(200, Headers, Req),
      State = #st{dbname=DbId, last_seq=Since, mode=eventsource},
      info(db_updated, Req2, State#st{subscribed=true}).
  
  
  
  