Exemplo n.º 1
0
        private static Task GetHealthStatus(IDictionary <string, object> environment, Func <HealthStatus> healthStatus)
        {
            var status  = healthStatus();
            var content = HealthCheckSerializer.Serialize(status);

            return(WriteResponse(environment, content, "application/json"));
        }
Exemplo n.º 2
0
        private dynamic GetHealthStatus()
        {
            var status  = Config.HealthStatus();
            var content = HealthCheckSerializer.Serialize(status);

            var response = Response.AsText(content, "application/json");

            response.StatusCode = status.IsHealty ? HttpStatusCode.OK : HttpStatusCode.InternalServerError;
            return(response);
        }
Exemplo n.º 3
0
        private Response GetHealthStatus()
        {
            var status  = Config.HealthStatus();
            var content = HealthCheckSerializer.Serialize(status);

            var response = Response.AsText(content, "application/json");

            if (!healthChecksAlwaysReturnHttpStatusOk)
            {
                response.StatusCode = status.IsHealty ? HttpStatusCode.OK : HttpStatusCode.InternalServerError;
            }
            else
            {
                response.StatusCode = HttpStatusCode.OK;
            }
            return(response);
        }
Exemplo n.º 4
0
        private static void WriteHealthStatus(HttpListenerContext context, Func <HealthStatus> healthStatus)
        {
            var status = healthStatus();
            var json   = HealthCheckSerializer.Serialize(status);

            context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
            context.Response.Headers.Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
            context.Response.ContentType = "application/json";

            context.Response.StatusCode        = status.IsHealty ? 200 : 500;
            context.Response.StatusDescription = status.IsHealty ? "OK" : "Internal Server Error";

            using (var writer = new StreamWriter(context.Response.OutputStream))
            {
                writer.Write(json);
            }
            context.Response.Close();
        }