diff --git a/main.go b/main.go index b65af72..5b44775 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,7 @@ func PurgeHandler(w http.ResponseWriter, r *http.Request) { url := r.URL.String() status := SendToVarnish(url) if status != "200 Purged" { - w.WriteHeader(http.StatusMethodNotAllowed) + w.WriteHeader(405) } io.WriteString(w, status) } @@ -63,7 +63,13 @@ func SendToVarnish(url string) string { return status } +// HealthHandler handles healthcheck requests and return 200. +func HealthHandler(w http.ResponseWriter, r *http.Request) { + io.WriteString(w, "OK") +} + func main() { http.HandleFunc("/", PurgeHandler) + http.HandleFunc("/healthcheck", HealthHandler) log.Fatal(http.ListenAndServe(":6081",nil)) }