fix(config): fix configuration management
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package api
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
@@ -99,11 +100,13 @@ func getCorrectedAltitude(db *database.Service) gin.HandlerFunc {
|
||||
}
|
||||
|
||||
func main() {
|
||||
cfg, err := config.Load()
|
||||
cfg, err := config.LoadConfig(".")
|
||||
if err != nil {
|
||||
log.Fatalf("Error loading configuration: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Config: %+v\n", cfg)
|
||||
|
||||
db, err := database.NewService(&cfg.Database)
|
||||
if err != nil {
|
||||
log.Fatalf("Could not initialize database: %v", err)
|
||||
@@ -113,8 +116,14 @@ func main() {
|
||||
|
||||
router := gin.Default()
|
||||
|
||||
// Servir les fichiers statiques (index.html, etc.) depuis le répertoire courant.
|
||||
router.StaticFS("/", http.Dir("."))
|
||||
// Configure les proxies de confiance pour Gin
|
||||
if len(cfg.Server.TrustedProxies) > 0 {
|
||||
router.SetTrustedProxies(cfg.Server.TrustedProxies)
|
||||
log.Printf("Trusted proxies set to: %v", cfg.Server.TrustedProxies)
|
||||
}
|
||||
|
||||
// Servir les fichiers statiques de l'UI go-app
|
||||
router.Static("/web", "./ui/web")
|
||||
|
||||
// La route est maintenant un POST pour recevoir un corps de requête JSON.
|
||||
router.POST("/getorthocorrec", getOrthometricCorrection(db))
|
||||
|
Reference in New Issue
Block a user