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
+102 -51
View File
@@ -24,6 +24,57 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/proxy/{path}": {
"get": {
"description": "Transparent proxy for Goong APIs to forward body, params, headers and inject API key automatically.",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/x-protobuf"
],
"tags": [
"Goong"
],
"summary": "Proxy Goong APIs",
"parameters": [
{
"type": "string",
"description": "Target URL to proxy, e.g., 'tiles.goong.io/assets/goong_map_web.json'",
"name": "path",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Resource content",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"403": {
"description": "Forbidden",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/auth/forgot-password": {
"post": {
"description": "Initiate password recovery process for a user",
@@ -1295,6 +1346,57 @@ const docTemplate = `{
}
}
},
"/map/proxy/{path}": {
"get": {
"description": "Transparent proxy for Goong APIs to forward body, params, headers and inject API key automatically.",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/x-protobuf"
],
"tags": [
"Goong"
],
"summary": "Proxy Goong APIs",
"parameters": [
{
"type": "string",
"description": "Target URL to proxy, e.g., 'tiles.goong.io/assets/goong_map_web.json'",
"name": "path",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Resource content",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"403": {
"description": "Forbidden",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/media": {
"get": {
"security": [
@@ -2699,57 +2801,6 @@ const docTemplate = `{
}
}
},
"/proxy/{path}": {
"get": {
"description": "Transparent proxy for Goong APIs to forward body, params, headers and inject API key automatically.",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/x-protobuf"
],
"tags": [
"Goong"
],
"summary": "Proxy Goong APIs",
"parameters": [
{
"type": "string",
"description": "Target URL to proxy, e.g., 'tiles.goong.io/assets/goong_map_web.json'",
"name": "path",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Resource content",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"403": {
"description": "Forbidden",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/raster-tiles/metadata": {
"get": {
"description": "Retrieve map metadata",
+102 -51
View File
@@ -17,6 +17,57 @@
},
"basePath": "/",
"paths": {
"/api/proxy/{path}": {
"get": {
"description": "Transparent proxy for Goong APIs to forward body, params, headers and inject API key automatically.",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/x-protobuf"
],
"tags": [
"Goong"
],
"summary": "Proxy Goong APIs",
"parameters": [
{
"type": "string",
"description": "Target URL to proxy, e.g., 'tiles.goong.io/assets/goong_map_web.json'",
"name": "path",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Resource content",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"403": {
"description": "Forbidden",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/auth/forgot-password": {
"post": {
"description": "Initiate password recovery process for a user",
@@ -1288,6 +1339,57 @@
}
}
},
"/map/proxy/{path}": {
"get": {
"description": "Transparent proxy for Goong APIs to forward body, params, headers and inject API key automatically.",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/x-protobuf"
],
"tags": [
"Goong"
],
"summary": "Proxy Goong APIs",
"parameters": [
{
"type": "string",
"description": "Target URL to proxy, e.g., 'tiles.goong.io/assets/goong_map_web.json'",
"name": "path",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Resource content",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"403": {
"description": "Forbidden",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/media": {
"get": {
"security": [
@@ -2692,57 +2794,6 @@
}
}
},
"/proxy/{path}": {
"get": {
"description": "Transparent proxy for Goong APIs to forward body, params, headers and inject API key automatically.",
"consumes": [
"application/json"
],
"produces": [
"application/json",
"application/x-protobuf"
],
"tags": [
"Goong"
],
"summary": "Proxy Goong APIs",
"parameters": [
{
"type": "string",
"description": "Target URL to proxy, e.g., 'tiles.goong.io/assets/goong_map_web.json'",
"name": "path",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Resource content",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"403": {
"description": "Forbidden",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/raster-tiles/metadata": {
"get": {
"description": "Retrieve map metadata",
+70 -35
View File
@@ -720,6 +720,41 @@ info:
title: History API
version: "1.0"
paths:
/api/proxy/{path}:
get:
consumes:
- application/json
description: Transparent proxy for Goong APIs to forward body, params, headers
and inject API key automatically.
parameters:
- description: Target URL to proxy, e.g., 'tiles.goong.io/assets/goong_map_web.json'
in: path
name: path
required: true
type: string
produces:
- application/json
- application/x-protobuf
responses:
"200":
description: Resource content
schema:
type: string
"400":
description: Bad Request
schema:
type: string
"403":
description: Forbidden
schema:
type: string
"500":
description: Internal Server Error
schema:
type: string
summary: Proxy Goong APIs
tags:
- Goong
/auth/forgot-password:
post:
consumes:
@@ -1545,6 +1580,41 @@ paths:
summary: Update application status
tags:
- Historian Application
/map/proxy/{path}:
get:
consumes:
- application/json
description: Transparent proxy for Goong APIs to forward body, params, headers
and inject API key automatically.
parameters:
- description: Target URL to proxy, e.g., 'tiles.goong.io/assets/goong_map_web.json'
in: path
name: path
required: true
type: string
produces:
- application/json
- application/x-protobuf
responses:
"200":
description: Resource content
schema:
type: string
"400":
description: Bad Request
schema:
type: string
"403":
description: Forbidden
schema:
type: string
"500":
description: Internal Server Error
schema:
type: string
summary: Proxy Goong APIs
tags:
- Goong
/media:
delete:
consumes:
@@ -2452,41 +2522,6 @@ paths:
summary: Get commit by ID
tags:
- Commits
/proxy/{path}:
get:
consumes:
- application/json
description: Transparent proxy for Goong APIs to forward body, params, headers
and inject API key automatically.
parameters:
- description: Target URL to proxy, e.g., 'tiles.goong.io/assets/goong_map_web.json'
in: path
name: path
required: true
type: string
produces:
- application/json
- application/x-protobuf
responses:
"200":
description: Resource content
schema:
type: string
"400":
description: Bad Request
schema:
type: string
"403":
description: Forbidden
schema:
type: string
"500":
description: Internal Server Error
schema:
type: string
summary: Proxy Goong APIs
tags:
- Goong
/raster-tiles/{z}/{x}/{y}:
get:
description: Fetch vector or raster map tile data by Z, X, Y coordinates
+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