1
0
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:
Lee Brown
2019-10-15 14:46:42 -08:00
parent 0bf7ca5387
commit 5dd7c02287
5 changed files with 44 additions and 6 deletions

View File

@ -1,8 +1,12 @@
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()
}