From ba5ac2df7d72c4ff055ab3839496fe2c4d9887c5 Mon Sep 17 00:00:00 2001 From: AzenKain Date: Mon, 18 May 2026 19:39:02 +0700 Subject: [PATCH] feat: implement GoongController to proxy requests with automatic API key injection --- internal/controllers/goongController.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/controllers/goongController.go b/internal/controllers/goongController.go index 8be4772..491e59e 100644 --- a/internal/controllers/goongController.go +++ b/internal/controllers/goongController.go @@ -2,6 +2,7 @@ package controllers import ( "history-api/internal/services" + "net/url" "strings" "github.com/gofiber/fiber/v3" @@ -41,6 +42,9 @@ func (ctrl *goongController) Proxy(c fiber.Ctx) error { } targetURL := path + if decodedURL, err := url.PathUnescape(targetURL); err == nil { + targetURL = decodedURL + } if strings.HasPrefix(targetURL, "https:/") && !strings.HasPrefix(targetURL, "https://") { targetURL = strings.Replace(targetURL, "https:/", "https://", 1) @@ -49,7 +53,11 @@ func (ctrl *goongController) Proxy(c fiber.Ctx) error { } if len(c.Request().URI().QueryString()) > 0 { - targetURL += "?" + string(c.Request().URI().QueryString()) + if strings.Contains(targetURL, "?") { + targetURL += "&" + string(c.Request().URI().QueryString()) + } else { + targetURL += "?" + string(c.Request().URI().QueryString()) + } } headers := make(map[string]string)