anchor.diff:              {error, timeout} ->
                   json_error(404, <<"Unknown drain.">>);
               Token when is_binary(Token) ->
  -                case logplex_drain:valid_uri(req_drain_uri(Req)) of
  +                case valid_uri(Req) of
                       {error, What} ->
                           logplex_drain:delete_partial_drain(DrainId, Token),
                           Err = io_lib:format("Invalid drain destination: ~p",
  
positive.code:     %% V2
      {['POST', "^/v2/channels/(\\d+)/drains$"], fun(Req, [ChannelIdStr]) ->
          ChannelId = list_to_integer(ChannelIdStr),
          case logplex_drain:valid_uri(req_drain_uri(Req)) of
              {error, What} ->
                  Err = io_lib:format("Invalid drain destination: ~p",
                                      [What]),
  
negative.code:                 undefined ->
                      {error, missing_host_param};
                  Host ->
                       logplex_drain:valid_uri(logplex_tcpsyslog_drain:uri(Host, Port))
              end;
          UrlString ->
              try
                  logplex_drain:valid_uri(
                    logplex_drain:parse_url(UrlString))
              catch
                  error:badarg ->
                      {error, UrlString}
              end            
      end.
  
     
  