Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

Commit

Permalink
talksapp: fix environment variable access
Browse files Browse the repository at this point in the history
Environment variables in Go are not accessible until a first request
arrives.

https://cloud.google.com/appengine/docs/go/config/appconfig#Go_app_yaml_Defining_environment_variables

The previous code was accessing them at variable declaration time,
obtaining empty values and causing authentication issues.

Change-Id: Id64e7c93453f9aded04d935cf49eccba0f9a6923
  • Loading branch information
Francesc Campoy committed Feb 12, 2016
1 parent 717c3ed commit 5c76757
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion talksapp/main.go
Expand Up @@ -35,7 +35,6 @@ var (
}
homeArticle = loadHomeArticle()
contactEmail = "golang-dev@googlegroups.com"
github = httputil.NewAuthTransportFromEnvironment(nil)

// used for mocking in tests
getPresentation = gosrc.GetPresentation
Expand Down Expand Up @@ -120,6 +119,8 @@ func writeTextHeader(w http.ResponseWriter, status int) {

func httpClient(r *http.Request) *http.Client {
c := appengine.NewContext(r)
github := httputil.NewAuthTransportFromEnvironment(nil)

return &http.Client{
Transport: &httputil.AuthTransport{
Token: github.Token,
Expand Down

0 comments on commit 5c76757

Please sign in to comment.