diff --git a/server/app/controllers/HealthController.scala b/server/app/controllers/HealthController.scala new file mode 100644 index 0000000..19040dd --- /dev/null +++ b/server/app/controllers/HealthController.scala @@ -0,0 +1,14 @@ +package controllers + +import javax.inject.Inject + +import controllers.common.{MyJsonController, MyJsonControllerComponents} + +class HealthController @Inject() ( + cc: MyJsonControllerComponents) + extends MyJsonController(cc) { + + def check() = Action { + Ok + } +} diff --git a/server/conf/routes b/server/conf/routes index 7955816..31bd55f 100644 --- a/server/conf/routes +++ b/server/conf/routes @@ -3,6 +3,8 @@ # https://www.playframework.com/documentation/latest/ScalaRouting # ~~~~ +GET /health controllers.HealthController.check() + GET /transactions/:txid controllers.TransactionsController.getTransaction(txid: String) GET /addresses/:address controllers.AddressesController.getDetails(address: String) diff --git a/server/test/controllers/HealthControllerSpec.scala b/server/test/controllers/HealthControllerSpec.scala new file mode 100644 index 0000000..200bd16 --- /dev/null +++ b/server/test/controllers/HealthControllerSpec.scala @@ -0,0 +1,18 @@ +package controllers + +import controllers.common.MyAPISpec +import play.api.Application +import play.api.test.Helpers._ + +class HealthControllerSpec extends MyAPISpec { + + val application: Application = guiceApplicationBuilder.build() + + "GET /health" should { + "return OK" in { + val response = GET("/health") + + status(response) mustEqual OK + } + } +} \ No newline at end of file