Skip to content

Commit

Permalink
Merge pull request #4 from everpeace/code-503-when-unhealthy
Browse files Browse the repository at this point in the history
change unhealthy status code to 503.
  • Loading branch information
everpeace authored Oct 27, 2017
2 parents 7662716 + 4e66b74 commit 5e5162f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ All you need to give is just health check function returning cats `ValidationNel

val response = Http().singleRequest(HttpRequest(uri = "http://localhost:8888/health"))

// status code is 200(OK) if healthy, 500(Internal Server Error) if unhealthy.
// status code is 200(OK) if healthy, 503(Service Unavailable) if unhealthy.
// response body is empty by default for performance.
// pass '?full=true' query parameter to see full check result as json. it would be similar to below.
// Please see com.github.everpeace.healthchecks.HealthRoutesTest for various response patterns.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object HealthCheckRoutes extends DecorateAsScala {

private def status(s: Boolean) = if (s) "healthy" else "unhealthy"

private def statusCode(s: Boolean) = if (s) OK else InternalServerError
private def statusCode(s: Boolean) = if (s) OK else ServiceUnavailable

private def toResultJson(check: HealthCheck, result: HealthCheckResult) =
HealthCheckResultJson(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ class HealthRoutesTest
val failedFatal = healthCheck("test3")(throw new Exception("exception"))

Get("/health") ~> HealthCheckRoutes.health(ok, failedButNonFatal, failedFatal) ~> check {
status shouldEqual InternalServerError
status shouldEqual ServiceUnavailable
responseAs[String] shouldEqual "{}"
}

Get("/health?full=true") ~> HealthCheckRoutes.health(ok, failedButNonFatal, failedFatal) ~> check {
status shouldEqual InternalServerError
status shouldEqual ServiceUnavailable
responseAs[String] shouldEqual
"""
|{
Expand Down

0 comments on commit 5e5162f

Please sign in to comment.