public ResponseExceptionHandlerMiddleware(RequestDelegate next, ILoggerFactory loggerFactory,
                                           IOptions <ResponseExceptionHandlerOptions> options)
 {
     _next    = next;
     _options = options.Value;
     _logger  = loggerFactory.CreateLogger <ResponseExceptionHandlerMiddleware>();
     _clearCacheHeadersDelegate = ClearCacheHeaders;
 }
        public static IApplicationBuilder UseResponseExceptionHandler(this IApplicationBuilder app, Action <ResponseExceptionHandlerOptions> setupAction)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            var options = new ResponseExceptionHandlerOptions();

            setupAction(options);

            return(app.UseMiddleware <ResponseExceptionHandlerMiddleware>(Options.Create(options)));
        }