Browse Source

server: Add GET /health endpoint

scalafmt-draft
Alexis Hernandez 7 years ago
parent
commit
d29b4b2f1c
  1. 14
      server/app/controllers/HealthController.scala
  2. 2
      server/conf/routes
  3. 18
      server/test/controllers/HealthControllerSpec.scala

14
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
}
}

2
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)

18
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
}
}
}
Loading…
Cancel
Save