Beispiel #1
0
func main() {
	flag.Parse()
	runtime.GOMAXPROCS(runtime.NumCPU())

	ctx = cloud.NewContext(projectID, &http.Client{
		Transport: google.NewComputeEngineConfig("").NewTransport(),
	})

	config, err := google.NewServiceAccountJSONConfig(*account, "https://www.googleapis.com/auth/userinfo.email")
	if err != nil {
		log.Fatal(err)
	}
	client = &http.Client{Transport: config.NewTransport()}

	http.HandleFunc("/healthcheck", func(http.ResponseWriter, *http.Request) {})
	http.HandleFunc("/", notificationHandler)
	log.Println("server listening on", listenAddress)

	if err := http.ListenAndServe(listenAddress, nil); err != nil {
		log.Fatal(err)
	}
}
Beispiel #2
0
func Example_computeEngine() {
	// If no other account is specified, "default" is used.
	config := google.NewComputeEngineConfig("")
	client := http.Client{Transport: config.NewTransport()}
	client.Get("...")
}