1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-11-29 23:07:40 +02:00

Don't log healthcheck and favicon requests

This commit is contained in:
DarthSim
2024-01-19 18:41:37 +03:00
parent 30f4fea1a1
commit 2026de092b
2 changed files with 40 additions and 16 deletions

View File

@@ -30,15 +30,12 @@ func buildRouter() *router.Router {
r := router.New(config.PathPrefix)
r.GET("/", handleLanding, true)
r.GET("/health", handleHealth, true)
if len(config.HealthCheckPath) > 0 {
r.GET(config.HealthCheckPath, handleHealth, true)
}
r.GET("/favicon.ico", handleFavicon, true)
r.GET("/", withMetrics(withPanicHandler(withCORS(withSecret(handleProcessing)))), false)
r.HEAD("/", withCORS(handleHead), false)
r.OPTIONS("/", withCORS(handleHead), false)
r.HealthHandler = handleHealth
return r
}
@@ -181,7 +178,10 @@ func handleHealth(reqID string, rw http.ResponseWriter, r *http.Request) {
ierr = ierrors.Wrap(err, 1)
}
router.LogResponse(reqID, r, status, ierr)
// Log response only if something went wrong
if ierr != nil {
router.LogResponse(reqID, r, status, ierr)
}
rw.Header().Set("Cache-Control", "no-cache")
rw.WriteHeader(status)
@@ -192,9 +192,3 @@ func handleHead(reqID string, rw http.ResponseWriter, r *http.Request) {
router.LogResponse(reqID, r, 200, nil)
rw.WriteHeader(200)
}
func handleFavicon(reqID string, rw http.ResponseWriter, r *http.Request) {
router.LogResponse(reqID, r, 200, nil)
// TODO: Add a real favicon maybe?
rw.WriteHeader(200)
}