Added health check for Kubernetes to use.

master
Michael 1 year ago
parent 9d5697fa44
commit 5f1ee177ba

@ -0,0 +1,16 @@
package controllers
import (
"net/http"
"github.com/gin-gonic/gin"
)
// GET /health
// Returns the health status of the application
func GetHealth(c *gin.Context) {
// TODO: Consider adding health checks to services this app relise on like queue and the database.
// Send our response
c.String(http.StatusOK, "ok")
}

@ -19,6 +19,8 @@ func main() {
// PodcastSeries Routes
r.GET("/podcast-series/:id", controllers.GetPodcastSeries)
r.POST("/podcast-series", controllers.CreatePodcastSeries)
// Health check route
r.GET("/health", controllers.GetHealth)
r.Run()
}

@ -10,7 +10,7 @@ import (
var DB *gorm.DB
func ConnectDatabase() {
dsn := "host=" + os.Getenv("locsi-podcasts-db-cluster-rw") + " user=" + os.Getenv("LOCSI_PODCASTS_DB_USER") + " password=" + os.Getenv("LOCSI_PODCASTS_DB_PASS") + " dbname=" + os.Getenv("LOCSI_PODCASTS_DB_NAME")
dsn := "host=locsi-podcasts-db-cluster-rw" + " user=" + os.Getenv("LOCSI_PODCASTS_DB_USER") + " password=" + os.Getenv("LOCSI_PODCASTS_DB_PASS") + " dbname=" + os.Getenv("LOCSI_PODCASTS_DB_NAME")
database, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil {

Loading…
Cancel
Save