anchor.diff:              Res = {struct, [{status, "error"},
                               {reason, "unknown sid"}]}
       end,
  -    {Res, NewS};
  -do_cmd(Unknown, _L, _Json, S) ->
  +    {{Res, []}, NewS};
  +do_cmd(Unknown, _L, _Json, _A, S) ->
       Error = lists:flatten(io_lib:format("unknown request: ~p", [Unknown])),
       error_logger:format("~s", [Error]),
  -    {{struct, [{"status", "error"}, {reason, Error}]}, S}.
  -
  -rpcreply(Response) ->
  +    {{{struct, [{"status", "error"}, {reason, Error}]}, []}, S}.
  +
  +rpcreply({Response, ExtraHeaders}) ->
       X = json2:encode(Response),
       [{header, {cache_control, "no-cache"}},
  -     {header, "Expires: -1"},
  -     {html, X}].
  +     {header, "Access-Control-Allow-Origin: *"},
  +     {header, "Expires: -1"}]++ExtraHeaders++[{html, X}].
   
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
  
positive.code:             Res = {struct, [{status, "error"},
                              {reason, "unknown sid"}]}
      end,
      {Res, NewS};
  %% http://idrott/idrott/del_user?sid=1234567890&username=jb
  do_cmd("del_user", L, _Json, S) ->
      Sid = get_val("sid", L, ""),
      case get_user_by_id(Sid, S) of
          U=#user{} when U#user.role == admin ->
              %% login successful
  
negative.code:             Res = {struct, [{status, "error"},
                              {reason, "unknown sid"}]}
      end,
      {{Res, []}, NewS};
  %% http://idrott/idrott/get_all_events?sid=1234567890
  do_cmd("get_all_events", L, _Json, A, S) ->
      Sid = get_sid(A,L),
      case get_user_by_id(Sid, S) of
          #user{} ->
              %% login successful
  