Skip to content

Commit

Permalink
Add debug
Browse files Browse the repository at this point in the history
  • Loading branch information
leszko committed Aug 21, 2024
1 parent b6576e7 commit 900e15f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions handlers/geolocation/geolocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (c *GeolocationHandlersCollection) RedirectHandler() httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
host := r.Host
pathType, prefix, playbackID, pathTmpl := parsePlaybackID(r.URL.Path)
glog.Warningf("### pathType=%s, prefix=%s, playbackID=%s, pathTmpl=%s", pathType, prefix, playbackID, pathTmpl)
redirectPrefixes := c.Config.RedirectPrefixes
isStudioReq := false

Expand Down Expand Up @@ -152,6 +153,7 @@ func (c *GeolocationHandlersCollection) RedirectHandler() httprouter.Handle {
}

nodeHost := c.Config.NodeHost
glog.Warningf("### nodeHost=%s, host=%s", nodeHost, host)

if nodeHost != "" && nodeHost != host {
newURL, err := url.Parse(r.URL.String())
Expand Down Expand Up @@ -185,6 +187,7 @@ func (c *GeolocationHandlersCollection) RedirectHandler() httprouter.Handle {

bestNode, fullPlaybackID, err := c.Balancer.GetBestNode(context.Background(), redirectPrefixes, playbackID, lat, lon, prefix, isStudioReq)

glog.Warningf("### bestNode=%s, fullPlaybackID=%s, err=%s", bestNode, fullPlaybackID, err)
if err != nil {
glog.Errorf("failed to find either origin or fallback server for playbackID=%s err=%s", playbackID, err)
w.WriteHeader(http.StatusBadGateway)
Expand All @@ -193,6 +196,7 @@ func (c *GeolocationHandlersCollection) RedirectHandler() httprouter.Handle {

rPath := fmt.Sprintf(pathTmpl, fullPlaybackID)
rURL := fmt.Sprintf("%s://%s%s?%s", protocol(r), bestNode, rPath, r.URL.RawQuery)
glog.Warning("### rURL=%s, rPath", rURL, rPath)
rURL, err = c.resolveNodeURL(rURL)
if err != nil {
glog.Errorf("failed to resolve node URL playbackID=%s err=%s", playbackID, err)
Expand Down

0 comments on commit 900e15f

Please sign in to comment.