mirror of
				https://github.com/SourceFellows/gobuch.git
				synced 2025-11-04 15:46:17 +01:00 
			
		
		
		
	initial import
This commit is contained in:
		
							
								
								
									
										31
									
								
								cloud-provider/google-cloud-hello/cmd/hello-world/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								cloud-provider/google-cloud-hello/cmd/hello-world/main.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
package main
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"os"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const defaultAddr = ":8080"
 | 
			
		||||
 | 
			
		||||
// main starts an http server on the $PORT environment variable.
 | 
			
		||||
func main() {
 | 
			
		||||
	addr := defaultAddr
 | 
			
		||||
	// $PORT environment variable is provided in the Kubernetes deployment.
 | 
			
		||||
	if p := os.Getenv("PORT"); p != "" {
 | 
			
		||||
		addr = ":" + p
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log.Printf("server starting to listen on %s", addr)
 | 
			
		||||
	http.HandleFunc("/", home)
 | 
			
		||||
	if err := http.ListenAndServe(addr, nil); err != nil {
 | 
			
		||||
		log.Fatalf("server listen error: %+v", err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// home logs the received request and returns a simple response.
 | 
			
		||||
func home(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	log.Printf("received request: %s %s", r.Method, r.URL.Path)
 | 
			
		||||
	fmt.Fprintf(w, "Hello, world!")
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user