github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/api/util/handlers.go (about) 1 package util 2 3 import ( 4 "net/http" 5 ) 6 7 // HealthCheckHandler is a basic "hey I'm fine" for load balancers & co 8 // TODO - add Database connection & proper configuration checks here for more accurate 9 // health reporting 10 func HealthCheckHandler(w http.ResponseWriter, r *http.Request) { 11 w.WriteHeader(http.StatusOK) 12 w.Write([]byte(`{ "meta": { "code": 200, "status": "ok" }, "data": null }`)) 13 } 14 15 // NotFoundHandler is a JSON 404 response 16 func NotFoundHandler(w http.ResponseWriter, r *http.Request) { 17 w.WriteHeader(http.StatusNotFound) 18 w.Write([]byte(`{ "meta": { "code": 404, "status": "not found" }, "data": null }`)) 19 } 20 21 // EmptyOkHandler is an empty 200 response, often used 22 // for OPTIONS requests that responds with headers set in addCorsHeaders 23 func EmptyOkHandler(w http.ResponseWriter, r *http.Request) { 24 w.WriteHeader(http.StatusOK) 25 }