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")); }
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); }
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); }
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(); }