Compare commits
1 Commits
v2023.4.21
...
v2023.4.21
Author | SHA1 | Date | |
---|---|---|---|
abc60b9ae3 |
@ -73,12 +73,7 @@ func (h *Handler) serveAppURL(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
from := req.From
|
from := req.From
|
||||||
if from == "" {
|
if from == "" {
|
||||||
host, _, err := net.SplitHostPort(r.RemoteAddr)
|
from = retrieveRemoteAddr(r)
|
||||||
if err != nil {
|
|
||||||
logger.Warn(ctx, "could not split remote address", logger.E(errors.WithStack(err)))
|
|
||||||
} else {
|
|
||||||
from = host
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
url, err := h.repo.GetURL(ctx, appID, from)
|
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)
|
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
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user