Adding healthcheck handler
This commit is contained in:
parent
fe42c2e3d4
commit
61d72cfc5b
8
main.go
8
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))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user