anchor.diff:      Method = Req:get(method),
       Path = Req:get(path),
       io:format("REQ: ~p ~p~n", [Method, Path]),
  -    %authorize(Req) andalso
       serve(handlers(), Method, Path, Req),
       ok.
   
   handlers() ->
       [{['GET', "/healthcheck"], fun(Req, _Match) ->
  +	authorize(Req),
           Count = logplex_stats:healthcheck(),
           Req:respond({200, [], integer_to_list(Count)})
       end},
   
       {['POST', "/channels$"], fun(Req, _Match) ->
  +	authorize(Req),
   	{struct, Params} = mochijson2:decode(Req:recv_body()),
           ChannelName = proplists:get_value(<<"name">>, Params),
           ChannelName == undefined andalso error_resp(Req, 400, <<"name post param missing">>),
  
positive.code:     end},
  
      {['POST', "/sessions"], fun(Req, _Match) ->
          Body = Req:recv_body(),
          Session = logplex_session:create(Body),
          not is_binary(Session) andalso error_resp(Req, 500, <<"failed to create session">>),
  
negative.code:     end.
  
  authorize(Req) ->
      AuthKey = os:getenv("LOGPLEX_AUTH_KEY"),
      case Req:get_header_value("Authorization") of
  	AuthKey ->
  	    true;
          _ ->
              Req:respond({401, [{"Content-Type", "text/html"}], "Not Authorized"}),
  	    throw(normal)
      end.
  
  error_resp(Req, RespCode, Body) ->
      Req:respond({RespCode, [{"Content-Type", "text/html"}], Body}),
  