Parcourir la source

Allow query params for health endpoint; Log health response

DarthSim il y a 6 ans
Parent
commit
2a7715540b
1 fichiers modifiés avec 8 ajouts et 3 suppressions
  1. 8 3
      server.go

+ 8 - 3
server.go

@@ -188,6 +188,12 @@ func respondWithOptions(reqID string, rw http.ResponseWriter) {
 	rw.WriteHeader(200)
 	rw.WriteHeader(200)
 }
 }
 
 
+func respondWithHealth(reqID string, rw http.ResponseWriter) {
+	logResponse(reqID, 200, string(imgproxyIsRunningMsg))
+	rw.WriteHeader(200)
+	rw.Write(imgproxyIsRunningMsg)
+}
+
 func respondWithNotModified(reqID string, rw http.ResponseWriter) {
 func respondWithNotModified(reqID string, rw http.ResponseWriter) {
 	logResponse(reqID, 200, "Not modified")
 	logResponse(reqID, 200, "Not modified")
 	rw.WriteHeader(304)
 	rw.WriteHeader(304)
@@ -266,9 +272,8 @@ func (h *httpHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
 		panic(errInvalidMethod)
 		panic(errInvalidMethod)
 	}
 	}
 
 
-	if r.URL.RequestURI() == healthPath {
-		rw.WriteHeader(200)
-		rw.Write(imgproxyIsRunningMsg)
+	if r.URL.Path == healthPath {
+		respondWithHealth(reqID, rw)
 		return
 		return
 	}
 	}