anchor.diff:      Json = {struct, [{error, <<"Not found">>}]},
       {404, iolist_to_binary(mochijson2:encode(Json))}.
   
  -req_drain_uri(Req) ->
  +json_error(Code, Err) ->
  +    {Code, ?JSON_CONTENT,
  +     mochijson2:encode({struct, [{error, iolist_to_binary(Err)}]})}.
  +
  +api_relative_url(_APIVSN, UUID) when is_binary(UUID) ->
  +    iolist_to_binary([<<"/sessions/">>, UUID]).
  +
  +end_chunked_response(Socket) ->
  +    gen_tcp:close(Socket),
  +    ok.
  +
  +uri_to_binary(Uri) ->
  +    iolist_to_binary(ex_uri:encode(Uri)).
  +
  +valid_uri(Req) ->
       {struct, Data} = mochijson2:decode(Req:recv_body()),
       case proplists:get_value(<<"url">>, Data) of
           undefined ->
  
positive.code:             {error, timeout} ->
                  json_error(404, <<"Unknown drain.">>);
              Token when is_binary(Token) ->
                  case logplex_drain:valid_uri(req_drain_uri(Req)) of
                      {error, What} ->
                          logplex_drain:delete_partial_drain(DrainId, Token),
                          Err = io_lib:format("Invalid drain destination: ~p",
  
negative.code:     %% V2
      {['POST', "^/v2/channels/(\\d+)/drains$"], fun(Req, [ChannelIdStr]) ->
          ChannelId = list_to_integer(ChannelIdStr),
          case valid_uri(Req) of
              {error, What} ->
                  Err = io_lib:format("Invalid drain destination: ~p",
                                      [What]),
  