update getUrl.go to use net/http

This commit is contained in:
orangix
2026-01-19 19:25:42 +01:00
parent bf849e1cbc
commit fd704f53e7

View File

@@ -1,18 +1,21 @@
package utils
import "github.com/gofiber/fiber/v2"
import "net/http"
func GetInstanceProtocol(c *fiber.Ctx) string {
func GetInstanceProtocol(r *http.Request) string {
proto := "https"
if !Config.Secure {
proto = "http"
}
if Config.ProtocolDetection {
proto = c.Get("X-Forwarded-Proto", proto)
xproto := r.Header.Get("X-Forwarded-Proto")
if xproto != "" {
proto = xproto
}
}
return proto
}
func GetInstanceUrl(c *fiber.Ctx) string {
return GetInstanceProtocol(c) + "://" + c.Hostname()
func GetInstanceUrl(r *http.Request) string {
return GetInstanceProtocol(r) + "://" + r.Host
}