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:
@ -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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user