feat: add goong integration service and route controllers with associated documentation
Build and Release / release (push) Successful in 1m41s

This commit is contained in:
2026-05-26 12:26:20 +07:00
parent 05059185af
commit cc92e07d92
6 changed files with 288 additions and 145 deletions
+8 -1
View File
@@ -34,7 +34,8 @@ func NewGoongController(goongService services.GoongService) GoongController {
// @Failure 400 {string} string "Bad Request"
// @Failure 403 {string} string "Forbidden"
// @Failure 500 {string} string "Internal Server Error"
// @Router /proxy/{path} [get]
// @Router /api/proxy/{path} [get]
// @Router /map/proxy/{path} [get]
func (ctrl *goongController) Proxy(c fiber.Ctx) error {
path := c.Params("*")
if path == "" {
@@ -69,12 +70,18 @@ func (ctrl *goongController) Proxy(c fiber.Ctx) error {
}
}
apiKeyName := "GOONG_API_KEY_REQ"
if strings.HasPrefix(c.Path(), "/map/proxy") {
apiKeyName = "GOONG_API_KEY_MAP"
}
statusCode, respHeaders, respBody, err := ctrl.goongService.ProxyRequest(
c.Context(),
c.Method(),
targetURL,
headers,
c.Body(),
apiKeyName,
)
if err != nil {
+2 -3
View File
@@ -7,7 +7,6 @@ import (
)
func GoongRoutes(app *fiber.App, goongController controllers.GoongController) {
api := app.Group("/proxy")
api.Get("/*", goongController.Proxy)
app.Get("/api/proxy/*", goongController.Proxy)
app.Get("/map/proxy/*", goongController.Proxy)
}
+4 -4
View File
@@ -17,7 +17,7 @@ import (
)
type GoongService interface {
ProxyRequest(ctx context.Context, method string, targetURL string, headers map[string]string, reqBody []byte) (int, map[string]string, []byte, error)
ProxyRequest(ctx context.Context, method string, targetURL string, headers map[string]string, reqBody []byte, apiKeyName string) (int, map[string]string, []byte, error)
}
type CacheEntry struct {
@@ -45,10 +45,10 @@ func NewGoongService(redis cache.Cache) GoongService {
}
}
func (s *goongService) ProxyRequest(ctx context.Context, method string, targetURL string, headers map[string]string, reqBody []byte) (int, map[string]string, []byte, error) {
apiKey, err := config.GetConfig("GOONG_API_KEY")
func (s *goongService) ProxyRequest(ctx context.Context, method string, targetURL string, headers map[string]string, reqBody []byte, apiKeyName string) (int, map[string]string, []byte, error) {
apiKey, err := config.GetConfig(apiKeyName)
if err != nil {
return 500, nil, nil, fmt.Errorf("GOONG_API_KEY is not configured")
return 500, nil, nil, fmt.Errorf("%s is not configured", apiKeyName)
}
fullTargetURL := targetURL