fix(module,app): use whole remote address if splitting fail
arcad/edge/pipeline/head This commit looks good
Details
arcad/edge/pipeline/head This commit looks good
Details
This commit is contained in:
parent
f99b1ac6ac
commit
abc60b9ae3
|
@ -73,12 +73,7 @@ func (h *Handler) serveAppURL(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
from := req.From
|
||||
if from == "" {
|
||||
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||
if err != nil {
|
||||
logger.Warn(ctx, "could not split remote address", logger.E(errors.WithStack(err)))
|
||||
} else {
|
||||
from = host
|
||||
}
|
||||
from = retrieveRemoteAddr(r)
|
||||
}
|
||||
|
||||
url, err := h.repo.GetURL(ctx, appID, from)
|
||||
|
@ -110,3 +105,12 @@ func Mount(repository Repository) MountFunc {
|
|||
r.Post("/api/v1/apps/{appID}/url", handler.serveAppURL)
|
||||
}
|
||||
}
|
||||
|
||||
func retrieveRemoteAddr(r *http.Request) string {
|
||||
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||
if err != nil {
|
||||
host = r.RemoteAddr
|
||||
}
|
||||
|
||||
return host
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue