Created
September 25, 2017 14:19
-
-
Save 0xAhmed/b49cae312e75f047dd512d5efc11ce14 to your computer and use it in GitHub Desktop.
Example Go app for hosting on k8s: Originally hosted at https://github.com/DockbitExamples/kubernetes/blob/master/app/app.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "net/http" | |
| ) | |
| const version string = "1.0" | |
| func getFrontpage(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "Congratulations! Version %s of your application is running on Kubernetes.", version) | |
| } | |
| func health(w http.ResponseWriter, r *http.Request) { | |
| w.WriteHeader(http.StatusOK) | |
| } | |
| func getVersion(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "%s\n", version) | |
| } | |
| func main() { | |
| http.HandleFunc("/", getFrontpage) | |
| http.HandleFunc("/health", health) | |
| http.HandleFunc("/version", getVersion) | |
| http.ListenAndServe(":8080", nil) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment