Last active
November 8, 2022 01:59
-
-
Save tardieu/6cca5ea4b5e0d227582b991598ea881d to your computer and use it in GitHub Desktop.
Knative sticky revisions: example golang server
This file contains 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" | |
"os" | |
) | |
func main() { | |
// http request handler | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
// set header on response with revision name | |
w.Header().Set("Knative-Serving-Tag", os.Getenv("K_REVISION")) | |
fmt.Fprintln(w, "OK") | |
}) | |
// start http server | |
fmt.Println(http.ListenAndServe(":8080", nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment