public HttpHandlerRegister WithHandler(IHttpHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            if (_handlerInstances.Contains(handler))
            {
                throw new InvalidOperationException(SR.HanderAlreadyExistsError);
            }

            _handlerInstances.Add(handler);

            WithAsyncSendingHandler(
                handler.GetPriority(HandlerType.Sending), async ctx =>
            {
                if (handler.Enabled)
                {
                    await handler.OnSending(ctx);
                }
            });

            WithAsyncSentHandler(handler.GetPriority(HandlerType.Sent), async ctx =>
            {
                if (handler.Enabled)
                {
                    await handler.OnSent(ctx);
                }
            });

            WithAsyncExceptionHandler(handler.GetPriority(HandlerType.Exception), async ctx =>
            {
                if (handler.Enabled)
                {
                    await handler.OnException(ctx);
                }
            });

            return(this);
        }