You've already forked golang-saas-starter-kit
mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-08-08 22:36:41 +02:00
Fix web-app reference to web-api docs
This commit is contained in:
@ -42,6 +42,19 @@ ARG code_path=./cmd/${name}
|
|||||||
ARG commit_ref=-
|
ARG commit_ref=-
|
||||||
ARG swagInit
|
ARG swagInit
|
||||||
|
|
||||||
|
ARG name
|
||||||
|
ARG code_path=./cmd/${name}
|
||||||
|
ARG commit_ref=-
|
||||||
|
|
||||||
|
ARG name
|
||||||
|
ENV SERVICE_NAME $name
|
||||||
|
|
||||||
|
ARG env="dev"
|
||||||
|
ENV ENV $env
|
||||||
|
|
||||||
|
ARG gogc="20"
|
||||||
|
ENV GOGC $gogc
|
||||||
|
|
||||||
# Copy shared packages.
|
# Copy shared packages.
|
||||||
COPY internal ./internal
|
COPY internal ./internal
|
||||||
|
|
||||||
|
@ -25,6 +25,15 @@ ARG name
|
|||||||
ARG code_path=./cmd/${name}
|
ARG code_path=./cmd/${name}
|
||||||
ARG commit_ref=-
|
ARG commit_ref=-
|
||||||
|
|
||||||
|
ARG name
|
||||||
|
ENV SERVICE_NAME $name
|
||||||
|
|
||||||
|
ARG env="dev"
|
||||||
|
ENV ENV $env
|
||||||
|
|
||||||
|
ARG gogc="20"
|
||||||
|
ENV GOGC $gogc
|
||||||
|
|
||||||
# Copy shared packages.
|
# Copy shared packages.
|
||||||
COPY internal ./internal
|
COPY internal ./internal
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func (h *Root) SitePage(ctx context.Context, w http.ResponseWriter, r *http.Requ
|
|||||||
tmpName = "site-api.gohtml"
|
tmpName = "site-api.gohtml"
|
||||||
|
|
||||||
// http://127.0.0.1:3001/docs/doc.json
|
// http://127.0.0.1:3001/docs/doc.json
|
||||||
swaggerJsonUrl := h.ProjectRoute.ApiDocsJson()
|
swaggerJsonUrl := h.ProjectRoute.ApiDocsJson(true)
|
||||||
|
|
||||||
// Load the json file from the API service.
|
// Load the json file from the API service.
|
||||||
res, err := pester.Get(swaggerJsonUrl)
|
res, err := pester.Get(swaggerJsonUrl)
|
||||||
|
@ -85,7 +85,7 @@ services:
|
|||||||
- configs/.env_docker_compose
|
- configs/.env_docker_compose
|
||||||
environment:
|
environment:
|
||||||
- WEB_APP_HTTP_HOST=:3000
|
- WEB_APP_HTTP_HOST=:3000
|
||||||
- WEB_APP_APP_BASE_URL=http://127.0.0.1:3000
|
- WEB_APP_APP_BASE_URL=http://localhost:3000
|
||||||
- WEB_APP_APP_DEBUG_HOST=:4000
|
- WEB_APP_APP_DEBUG_HOST=:4000
|
||||||
- WEB_APP_REDIS_HOST=redis:6379
|
- WEB_APP_REDIS_HOST=redis:6379
|
||||||
- WEB_APP_DB_HOST=postgres:5432
|
- WEB_APP_DB_HOST=postgres:5432
|
||||||
@ -93,7 +93,8 @@ services:
|
|||||||
- WEB_APP_DB_PASS=postgres
|
- WEB_APP_DB_PASS=postgres
|
||||||
- WEB_APP_DB_DATABASE=shared
|
- WEB_APP_DB_DATABASE=shared
|
||||||
- WEB_APP_DB_DISABLE_TLS=true
|
- WEB_APP_DB_DISABLE_TLS=true
|
||||||
- WEB_API_BASE_URL=http://web-api:3001
|
- WEB_API_BASE_URL=http://localhost:3001
|
||||||
|
- USE_NETWORK_ALIAS=1
|
||||||
- DD_TRACE_AGENT_HOSTNAME=datadog
|
- DD_TRACE_AGENT_HOSTNAME=datadog
|
||||||
- DD_TRACE_AGENT_PORT=8126
|
- DD_TRACE_AGENT_PORT=8126
|
||||||
- DD_SERVICE_NAME=web-app
|
- DD_SERVICE_NAME=web-app
|
||||||
@ -125,7 +126,7 @@ services:
|
|||||||
- configs/.env_docker_compose
|
- configs/.env_docker_compose
|
||||||
environment:
|
environment:
|
||||||
- WEB_API_HTTP_HOST=:3001
|
- WEB_API_HTTP_HOST=:3001
|
||||||
- WEB_API_APP_BASE_URL=http://127.0.0.1:3001
|
- WEB_API_APP_BASE_URL=http://localhost:3001
|
||||||
- WEB_API_APP_DEBUG_HOST=:4001
|
- WEB_API_APP_DEBUG_HOST=:4001
|
||||||
- WEB_API_REDIS_HOST=redis:6379
|
- WEB_API_REDIS_HOST=redis:6379
|
||||||
- WEB_API_DB_HOST=postgres:5432
|
- WEB_API_DB_HOST=postgres:5432
|
||||||
@ -133,7 +134,8 @@ services:
|
|||||||
- WEB_API_DB_PASS=postgres
|
- WEB_API_DB_PASS=postgres
|
||||||
- WEB_API_DB_DATABASE=shared
|
- WEB_API_DB_DATABASE=shared
|
||||||
- WEB_API_DB_DISABLE_TLS=true
|
- WEB_API_DB_DISABLE_TLS=true
|
||||||
- WEB_APP_BASE_URL=http://web-app:3000
|
- WEB_APP_BASE_URL=http://localhost:3000
|
||||||
|
- USE_NETWORK_ALIAS=1
|
||||||
- DD_TRACE_AGENT_HOSTNAME=datadog
|
- DD_TRACE_AGENT_HOSTNAME=datadog
|
||||||
- DD_TRACE_AGENT_PORT=8126
|
- DD_TRACE_AGENT_PORT=8126
|
||||||
- DD_SERVICE_NAME=web-app
|
- DD_SERVICE_NAME=web-app
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package project_route
|
package project_route
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProjectRoute struct {
|
type ProjectRoute struct {
|
||||||
@ -58,8 +62,18 @@ func (r ProjectRoute) ApiDocs() string {
|
|||||||
return u.String()
|
return u.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r ProjectRoute) ApiDocsJson() string {
|
func (r ProjectRoute) ApiDocsJson(internal bool) string {
|
||||||
u := r.webApiUrl
|
u := r.webApiUrl
|
||||||
|
|
||||||
|
if ev := os.Getenv("USE_NETWORK_ALIAS"); ev != "" {
|
||||||
|
if internal && strings.Contains(u.Host, ":") {
|
||||||
|
h, p, _ := net.SplitHostPort(u.Host)
|
||||||
|
if h == "127.0.0.1" || h == "localhost" {
|
||||||
|
u.Host = fmt.Sprintf("web-api:%s", p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
u.Path = "/docs/doc.json"
|
u.Path = "/docs/doc.json"
|
||||||
return u.String()
|
return u.String()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user