Using Redirects in GAE

0 views
Skip to first unread message

Colin Adler via StackOverflow

unread,
Oct 11, 2015, 11:18:03 PM10/11/15
to google-appengin...@googlegroups.com

I am fairly new to Go, and I am trying to make a few apps for GAE. I couldn't find anyone with the same problem as me so I thought I would ask here!

Basically, I am creating a program that will take a random url from an array and redirect the user.

The problem that arises is that on every computer I try it on, it will send a different video, but it will always send the same video to that person.

If anyone has any insight into this it would be greatly appreciated!

    package randvid

    import (
        "net/http"
        "math/rand"
        "time"
    )

    func RandLink() string{
      VideoList := []string{
        ...
      }
      r := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
      vid := r.Intn(len(VideoList)) + 1;
      return VideoList[vid]
    }

    func redirectHandler(path string) func(http.ResponseWriter, *http.Request) {
      return func (w http.ResponseWriter, r *http.Request) {
        http.Redirect(w, r, path, http.StatusMovedPermanently)
      }
    }

    func init() {
      http.HandleFunc("/", redirectHandler(RandLink()))
    }


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/33072737/using-redirects-in-gae

Bravada Zadada via StackOverflow

unread,
Oct 12, 2015, 12:48:10 AM10/12/15
to google-appengin...@googlegroups.com

Your clients are probably caching the 301 response as allowed by RFC 2616.

Change the response status code to 202, http.StatusFound.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/33072737/using-redirects-in-gae/33073462#33073462
Reply all
Reply to author
Forward
0 new messages