diff --git a/apps/backend/server.go b/apps/backend/server.go index 418c6d4..f8d07ac 100644 --- a/apps/backend/server.go +++ b/apps/backend/server.go @@ -22,8 +22,29 @@ func main() { u = NewUpdater() e := echo.New() - e.Use(middleware.RequestLogger()) + skipper := func(c *echo.Context) bool { + // Skip health check endpoint + return c.Request().URL.Path == "/health" + } + e.Use(middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{ + LogStatus: true, + LogURI: true, + LogMethod: true, + Skipper: skipper, + HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code + LogValuesFunc: func(c *echo.Context, v middleware.RequestLoggerValues) error { + var errMsg string + if v.Error != nil { + errMsg = fmt.Sprintf(" ERROR: %s", v.Error.Error()) + } + fmt.Printf("[%s %s]: %d%s\n", v.Method, v.URI, v.Status, errMsg) + return nil + }, + })) + e.GET("/", func(c *echo.Context) error { + return c.String(http.StatusOK, "OK") + }) e.GET("/test", func(c *echo.Context) error { return c.JSONPretty(http.StatusOK, diff --git a/docker-compose.yml b/docker-compose.yml index db92106..422cd4e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -81,7 +81,7 @@ services: IMAGEOPTION: "true" CONCURRENT_IMAGES: ${CONCURRENT_IMAGES} healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:1323/health"] + test: ["CMD", "curl", "-f", "http://localhost:1323"] interval: 10s timeout: 5s retries: 5