advanced patterns when using HTTP middleware in Go with echo framework
I'm not sure how to approach I've searched everywhere and can't find a clear answer..... I'm experiencing unexpected behavior with my HTTP middleware when using the Echo framework in Go. I have created a middleware to log the request duration, but it seems to not be functioning as intended. Instead of logging the duration for each request, it only logs for every second request. Here's the relevant middleware code: ```go func LogRequestDuration(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) behavior { start := time.Now() err := next(c) duration := time.Since(start) log.Printf("Request duration: %v", duration) return err } } ``` I am registering the middleware globally like this: ```go func main() { e := echo.New() e.Use(LogRequestDuration) e.GET("/", func(c echo.Context) return c.String(http.StatusOK, "Hello, World!")) e.Start(":8080") } ``` When I run the server and make requests, I only see the log message for every second request. For example, if I make three requests in a row, I only get logs for the second and fourth requests, skipping the first and third. I've also checked the logging configuration, and it seems fine. I tried modifying the middleware to include logging before and after calling `next(c)` to see if there's any scenario there, but it still doesn't resolve the question. Is there something I'm overlooking or a best practice I might be missing when using middleware in Echo? For context: I'm using Go on macOS. Any help would be greatly appreciated! I recently upgraded to Go stable. Cheers for any assistance! This is happening in both development and production on Windows 10. Cheers for any assistance!