Commit 5dd7c022 authored by Lee Brown's avatar Lee Brown

Fix web-app reference to web-api docs

parent 0bf7ca53
......@@ -42,6 +42,19 @@ ARG code_path=./cmd/${name}
ARG commit_ref=-
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 internal ./internal
......
......@@ -25,6 +25,15 @@ 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 internal ./internal
......
......@@ -56,7 +56,7 @@ func (h *Root) SitePage(ctx context.Context, w http.ResponseWriter, r *http.Requ
tmpName = "site-api.gohtml"
// 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.
res, err := pester.Get(swaggerJsonUrl)
......
......@@ -85,7 +85,7 @@ services:
- configs/.env_docker_compose
environment:
- 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_REDIS_HOST=redis:6379
- WEB_APP_DB_HOST=postgres:5432
......@@ -93,7 +93,8 @@ services:
- WEB_APP_DB_PASS=postgres
- WEB_APP_DB_DATABASE=shared
- 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_PORT=8126
- DD_SERVICE_NAME=web-app
......@@ -125,7 +126,7 @@ services:
- configs/.env_docker_compose
environment:
- 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_REDIS_HOST=redis:6379
- WEB_API_DB_HOST=postgres:5432
......@@ -133,7 +134,8 @@ services:
- WEB_API_DB_PASS=postgres
- WEB_API_DB_DATABASE=shared
- 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_PORT=8126
- DD_SERVICE_NAME=web-app
......
package project_route
import (
"fmt"
"github.com/pkg/errors"
"net"
"net/url"
"os"
"strings"
)
type ProjectRoute struct {
......@@ -58,8 +62,18 @@ func (r ProjectRoute) ApiDocs() string {
return u.String()
}
func (r ProjectRoute) ApiDocsJson() string {
func (r ProjectRoute) ApiDocsJson(internal bool) string {
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"
return u.String()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment