fix: GeoIP opcional, no paniquea si falta GeoLite2-City.mmdb

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-20 10:22:55 -05:00
co-authored by Claude Sonnet 4.6
parent e28e2823dc
commit d66fe95514
2 changed files with 7 additions and 5 deletions
+3 -3
View File
@@ -36,11 +36,11 @@ func LoadBuiltInMiddlewares(app *config.AppConfig) {
func Location(c *fiber.Ctx) (string, error) {
if Http.GeoIP == nil {
return "127.0.0.1", nil
}
ip := IP(c)
_, err := Http.GeoIP.GetLocation(ip)
if err != nil {
return "127.0.0.1", err
}
return "127.0.0.1", err
}
+4 -2
View File
@@ -52,8 +52,10 @@ func (cfg *AppConfig) Setup() {
modelFile := filepath.Join(cfg.Server.AssetPath, "rbac_model.conf")
cfg.Auth.Setup(cfg.Database.DB, modelFile)
}
path := MakeDir(filepath.Join(cfg.Server.AssetPath, "GeoLite2-City.mmdb"))
cfg.GeoIP = ip.NewGeoIpDB(path)
mmdbPath := filepath.Join(cfg.Server.AssetPath, "GeoLite2-City.mmdb")
if _, err := os.Stat(mmdbPath); err == nil {
cfg.GeoIP = ip.NewGeoIpDB(MakeDir(mmdbPath))
}
}
func (cfg *AppConfig) PrepareLog() {