add gin_mode env
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/rideaware/admin-panel/internal/config"
|
||||
"github.com/rideaware/admin-panel/internal/database"
|
||||
@@ -17,11 +18,22 @@ import (
|
||||
// authenticated routes, and starts the HTTP server on the configured port.
|
||||
func main() {
|
||||
cfg := config.Load()
|
||||
|
||||
// Set Gin mode based on environment (default to release)
|
||||
if os.Getenv("GIN_MODE") == "" {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
middleware.Init()
|
||||
database.Init(cfg)
|
||||
defer database.Close()
|
||||
|
||||
router := gin.Default()
|
||||
router := gin.New()
|
||||
router.Use(gin.Logger())
|
||||
router.Use(gin.Recovery())
|
||||
|
||||
// Trust only localhost proxy in production
|
||||
router.SetTrustedProxies([]string{"127.0.0.1", "localhost", "::1"})
|
||||
|
||||
router.LoadHTMLGlob("web/templates/*.html")
|
||||
router.Static("/static", "web/static")
|
||||
|
||||
Reference in New Issue
Block a user