Skip to content

Instantly share code, notes, and snippets.

@tardieu
Last active November 8, 2022 01:59
Show Gist options
  • Save tardieu/6cca5ea4b5e0d227582b991598ea881d to your computer and use it in GitHub Desktop.
Save tardieu/6cca5ea4b5e0d227582b991598ea881d to your computer and use it in GitHub Desktop.
Knative sticky revisions: example golang server
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