package main
import (
"fmt"
"log"
"net/http"
"os"
)
var (
version string
subtitle string
color string
)
const htmlContent = `
Deployment Demonstration
%[1]s
%[2]s
`
func deploymentHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, htmlContent, version, subtitle, color)
}
func healthHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "ok")
}
func main() {
version = "v1"
if len(os.Args) > 1 {
version = os.Args[1]
}
subtitle = os.Getenv("SUBTITLE")
color = os.Getenv("COLOR")
if len(color) == 0 {
color = "#303030"
}
http.HandleFunc("/", deploymentHandler)
http.HandleFunc("/_healthz", healthHandler)
log.Printf("Listening on :8080 at %s ...", version)
log.Fatal(http.ListenAndServe(":8080", nil))
}