This commit is contained in:
Lizandro Guarnizo
2026-05-18 23:50:50 -05:00
parent bbe83c79ba
commit 7f309186d6
10 changed files with 73 additions and 22 deletions
+29 -5
View File
@@ -10,8 +10,21 @@ import (
"github.com/sujit-baniya/fiber-boilerplate/app"
)
// getAppURL devuelve la URL base absoluta (sin slash final).
// Si APP_URL es http://localhost sin puerto, añade APP_PORT para enlaces en desarrollo.
// GetPublicURL devuelve la URL pública para enlaces en correos, Telegram y webhooks.
func GetPublicURL() string {
return getPublicURL()
}
// getPublicURL usa APP_PUBLIC_URL si está configurada; si no, APP_URL (con puerto en localhost).
func getPublicURL() string {
if u := normalizeBaseURL(app.Http.Server.PublicUrl); u != "" {
return u
}
return getAppURL()
}
// getAppURL devuelve la URL base de la app (sin slash final).
// Si APP_URL es http://localhost sin puerto, añade APP_PORT para desarrollo local.
func getAppURL() string {
u := strings.TrimRight(app.Http.Server.Url, "/")
if u == "" {
@@ -33,10 +46,21 @@ func getAppURL() string {
return u
}
// absAppURL convierte una ruta relativa en URL absoluta para correo/Telegram.
func normalizeBaseURL(raw string) string {
u := strings.TrimSpace(strings.TrimRight(raw, "/"))
if u == "" {
return ""
}
if !strings.Contains(u, "://") {
u = "https://" + u
}
return strings.TrimRight(u, "/")
}
// absAppURL convierte una ruta relativa en URL absoluta pública (correo/Telegram).
func absAppURL(path string) string {
if path == "" {
return getAppURL()
return getPublicURL()
}
if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") {
return path
@@ -44,7 +68,7 @@ func absAppURL(path string) string {
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
return getAppURL() + path
return getPublicURL() + path
}
func adminTicketPath(ticketID uint) string {