public static Task WriteHealthCheckUIResponse(IOwinContext httpContext, HealthReport report, Action <JsonSerializerSettings> jsonConfigurator, string role)
        {
            if (!string.IsNullOrEmpty(role) && !httpContext.Authentication.User.IsInRole(role))
            {
                return(httpContext.Response.WriteAsync($"You are not authorized for this {role}!"));
            }
            var response = "{}";

            if (report != null)
            {
                var settings = new JsonSerializerSettings()
                {
                    ContractResolver = new DefaultContractResolver
                    {
                        NamingStrategy = new CamelCaseNamingStrategy
                        {
                            ProcessDictionaryKeys = false
                        }
                    },
                    NullValueHandling     = NullValueHandling.Ignore,
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                };

                jsonConfigurator?.Invoke(settings);

                settings.Converters.Add(new StringEnumConverter());

                httpContext.Response.ContentType = DEFAULT_CONTENT_TYPE;

                var uiReport = UIHealthReport
                               .CreateFrom(report);

                response = JsonConvert.SerializeObject(uiReport, settings);
            }

            return(httpContext.Response.WriteAsync(response));
        }