Files
devops-directive-docker-course/04-building-container-images/sample-app/api-golang/main.go
2023-01-23 10:48:02 -05:00

33 lines
490 B
Go

package main
import (
"log"
"os"
"github.com/gin-gonic/gin"
"api-golang/database"
)
func init() {
errDB := database.InitDB(os.Getenv("DATABASE_URL"))
if errDB != nil {
log.Fatalf("⛔ Unable to connect to database: %v\n", errDB)
} else {
log.Println("DATABASE CONNECTED 🥇")
}
}
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
database.GetTime(c)
c.JSON(200, gin.H{
"message": "pong",
})
})
r.Run() // listen and serve on 0.0.0.0:8080
}