Created
April 5, 2020 07:27
-
-
Save obszczymucha/0f58afc32eaf9caa87694b2e38d70a43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object HealthCheckRoute { | |
implicit val healthCheckEncoder: Encoder[HealthCheck] = deriveEncoder[HealthCheck] | |
implicit def healthCheckEntityEncoder[F[_] : Sync]: EntityEncoder[F, HealthCheck] = jsonEncoderOf | |
def healthCheck[F[_] : Sync](service: HealthCheckService[F]): HttpRoutes[F] = { | |
val dsl = new Http4sDsl[F]() {} | |
import dsl._ | |
HttpRoutes.of[F] { | |
case GET -> Root / "health-check" => for { | |
healthCheck <- service.healthCheck | |
response <- healthCheck.fold(l => ServiceUnavailable(l), r => Ok(r)) | |
} yield response | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment