anchor.diff:  -export([write_json/2]).
   -export([delete_resource/2]).
   
  --record(state, {path, segments, hash, hashes, etag, mode, access}).
  +-record(state, {path, segments, hash, hashes, etag, mode, access, callbacks}).
   
   init(_Transport, _Req, _Opts) ->
       {upgrade, protocol, cowboy_rest}.
  
positive.code:         undefined ->
              {true, Req0, State};
          _ ->
              Q = <<"select access from tokens where path <@ hstore($1::text[]) and id=$2">>,
              case cloudstore_pg:equery(cloudstore_pool, Q, [segments_to_hprops(Segments), Token]) of
                  {ok, _, []} ->
                      {true, Req0, State};
                  {ok, _, [{Access}]} ->
                      {false, Req0, State#state{access = Access}}
              end
      end.
  
  
negative.code: segments_to_hprops(Segments) ->
      lists:append(lists:foldl(fun({expr, star}, R) -> [[] | R]; (Value, R) -> [[list_to_binary(integer_to_list(length(R))), Value] | R] end, [], Segments)).
  
  fire_callbacks(#state{callbacks = Callbacks}) ->
      io:format("~p~n", [Callbacks]).
  
  write_json(Req, #state{access = Access, mode = pointer, hash = undefined, path = Path, segments = Segments} = State) when Access =:= <<"rw">> ->
      {ok, Json, Req0} = cowboy_req:body(Req),
      Props = case jiffy:decode(Json) of
  