I am trying to discover other deployed services on the App Engine. Something like this article suggests.
This is how my code looks like:
import (
"fmt"
"net/http"
"google.golang.org/appengine"
)
func ServiceHostname(serviceName string, r *http.Request) (string, error) {
ctx := appengine.NewContext(r)
hostname, err := appengine.ModuleHostname(ctx, serviceName, "", "")
if err != nil {
return "", fmt.Errorf("unable to find service %s: %v", serviceName, err)
}
return hostname, nil
}
I am calling this function in a regular http handler. The error I've got is: not an App Engine context
.
The only difference in between my code and the referenced article is in app engine go version. I am using the new go111
where he's using go1
runtime.
Do you know how to overcome the issue?