/// <summary>
        /// Registers the middleware into the HTTP request pipeline.
        /// </summary>
        /// <param name="builder"><see cref="IApplicationBuilder"/> instance.</param>
        /// <param name="action"><see cref="Action{HttpRequestHeaderHandlerMiddlewareOptions}"/> delegate.</param>
        /// <returns>Returns the <see cref="IApplicationBuilder"/> instance that contains the middleware.</returns>
        public static IApplicationBuilder UseHttpRequestHeaderHandler(this IApplicationBuilder builder, Action <HttpRequestHeaderHandlerMiddlewareOptions> action = null)
        {
            if (builder == null)
            {
                return(null);
            }

            HttpRequestHeaderHandlerMiddlewareOptions options;

            if (action == null)
            {
                options = new HttpRequestHeaderHandlerMiddlewareOptions()
                {
                    Headers =
                    {
                        new HttpRequestHeader()
                        {
                            Url      = "http://localhost",
                            Prefixes ={ "/api"                }
                        }
                    }
                };

                return(UseHttpRequestHeaderHandler(builder, options));
            }

            options = new HttpRequestHeaderHandlerMiddlewareOptions();
            action.Invoke(options);

            return(UseHttpRequestHeaderHandler(builder, options));
        }
        /// <summary>
        /// Initialises a new instance of the <see cref="HttpRequestHeaderHandlerMiddleware"/> class.
        /// </summary>
        /// <param name="next"><see cref="RequestDelegate"/> delegate.</param>
        /// <param name="options"><see cref="IOptions{HttpRequestHeaderHandlerMiddlewareOptions}"/> instance.</param>
        public HttpRequestHeaderHandlerMiddleware(RequestDelegate next, IOptions <HttpRequestHeaderHandlerMiddlewareOptions> options)
        {
            this._next    = next;
            this._options = options.Value;

            this._headersToExclude = new List <string>()
            {
                "Content-Length", "Content-Type", "HeaderHost"
            };
            this._methodsRequireContent = new List <string>()
            {
                "POST", "PUT", "PATCH"
            };
        }
        /// <summary>
        /// Registers the middleware into the HTTP request pipeline.
        /// </summary>
        /// <param name="builder"><see cref="IApplicationBuilder"/> instance.</param>
        /// <param name="options"><see cref="HttpRequestHeaderHandlerMiddlewareOptions"/> instance.</param>
        /// <returns>Returns the <see cref="IApplicationBuilder"/> instance that contains the middleware.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="options"/> is <see langword="null" />.</exception>
        public static IApplicationBuilder UseHttpRequestHeaderHandler(this IApplicationBuilder builder, HttpRequestHeaderHandlerMiddlewareOptions options)
        {
            if (builder == null)
            {
                return(builder);
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(builder.UseMiddleware <HttpRequestHeaderHandlerMiddleware>(Options.Create(options)));
        }