I am using Flexible Environment in App engine I want to send HTTP Get request in my code.
ctx := appengine.NewContext(r)
client := urlfetch.Client(ctx)
req, err := http.NewRequest("GET", "https://www.google.com/", nil)
res, err := client.Do(req)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Fprintf(w, "HTTP GET returned status %v", res.Status)
When I run app I get the following error: https://www.google.com/: not an App Engine context
The above code works in Standard Environment and but it is not working in flexible environment.
You don't need URL Fetch in App Engine Flexible, you can simply issue the http request: https://cloud.google.com/appengine/docs/flexible/go/migrating#url_fetch