Use companion objects for static version and health

This commit is contained in:
Stedoss 2025-03-10 22:41:24 +00:00
parent 85ffbbf244
commit ad112e7b40
2 changed files with 14 additions and 10 deletions

View File

@ -8,15 +8,17 @@ data class HealthResponse(
val healthy: Boolean, val healthy: Boolean,
) )
val healthResponse = HealthResponse(
healthy = true,
)
@RestController @RestController
class HealthController { class HealthController {
companion object {
val HEALTH = HealthResponse(
healthy = true,
)
}
@GetMapping("/health") @GetMapping("/health")
fun healthCheck(): ResponseEntity<HealthResponse> { fun healthCheck(): ResponseEntity<HealthResponse> {
return ResponseEntity.ok(healthResponse) return ResponseEntity.ok(HEALTH)
} }
} }

View File

@ -8,12 +8,14 @@ data class VersionResponse(
val version: String, val version: String,
) )
val versionResponse = VersionResponse(
version = "v20250310",
)
@RestController @RestController
class VersionController { class VersionController {
@GetMapping("/version") companion object {
fun getVersion(): ResponseEntity<VersionResponse> = ResponseEntity.ok(versionResponse) val VERSION = VersionResponse(
version = "v20250310",
)
}
@GetMapping("/version")
fun getVersion(): ResponseEntity<VersionResponse> = ResponseEntity.ok(VERSION)
} }