anchor.diff:  -export([init/3
            ,rest_init/2
            ,allowed_methods/2
  +         ,is_authorized/2
            ,known_content_type/2
            ,malformed_request/2
            ,process_post/2
  
positive.code:         ]).
  
  -record(state, {token :: logpex_token:id(),
                  msgs :: list()}).
  
  child_spec() ->
  
negative.code: 
  allowed_methods(Req, State) ->
      {['POST'], Req, State}.
  
  is_authorized(Req, State) ->
      case cowboy_http_req:header(<<"Authorization">>, Req) of
          {<<"Basic ", Base64/binary>>, Req2} ->
              case binary:split(base64:decode(Base64), <<":">>) of
                  [_User, TokenId = <<"t.", _/binary>>] ->
                      case logplex_token:lookup(TokenId) of
                          undefined ->
                              {{false, <<"Basic realm=Logplex">>}, Req2, State};
                          Token ->
                              Name = logplex_token:name(Token),
                              ChanId = logplex_token:channel_id(Token),
                              {true, Req2, State#state{name=Name,
                                                       channel_id=ChanId}}
                      end;
                  _ ->
                      {{false, <<"Basic realm=Logplex">>}, Req2, State}
              end;
          {_, Req2} ->
              {{false, <<"Basic realm=Logplex">>}, Req2, State}
      end.
  
  known_content_type(Req, State) ->
      case cowboy_http_req:header(<<"Content-Type">>, Req) of
  