Skip to content

Commit

Permalink
Merge pull request #55 from betagouv/main
Browse files Browse the repository at this point in the history
add healthcheck
  • Loading branch information
ssedoudbgouv authored Oct 14, 2024
2 parents a456919 + 3956251 commit aee1caf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class SignalConsoComponents(
lazy val router: Router =
new _root_.router.Routes(
httpErrorHandler,
new HealthController(controllerComponents),
companyController
)

Expand Down
20 changes: 20 additions & 0 deletions app/controllers/HealthController.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package controllers

import play.api.libs.json.Json
import play.api.mvc.AbstractController
import play.api.mvc.ControllerComponents

import scala.concurrent.ExecutionContext
import scala.concurrent.Future

class HealthController(
controllerComponents: ControllerComponents
)(implicit val ec: ExecutionContext)
extends AbstractController(controllerComponents) {

def health =
Action.async(parse.empty) { _ =>
Future.successful(Ok(Json.obj("name" -> "signalconso-entreprise")))
}

}
1 change: 1 addition & 0 deletions app/controllers/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import scala.concurrent.Future
package object controllers {

val logger: Logger = Logger(this.getClass)

implicit class RequestOps[T <: JsValue](request: Request[T])(implicit ec: ExecutionContext) {
def parseBody[B](path: JsPath = JsPath())(implicit reads: Reads[B]) = request.body
.validate[B](path.read[B])
Expand Down
1 change: 1 addition & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This file defines all application routes (Higher priority routes first)
# ~~~~

GET / controllers.HealthController.health

GET /api/companies/search/smart controllers.EtablissementController.searchSmart(q: String, postalCode: Option[String], departmentCode: Option[String], lang: java.util.Locale)
GET /api/companies/search/:identity controllers.EtablissementController.searchEtablissementByIdentity(identity: String, openOnly :Option[Boolean], lang: Option[java.util.Locale])
Expand Down

0 comments on commit aee1caf

Please sign in to comment.