Echo middleware
Echo’s middleware works similarly to the regular Go HTTP middleware, but Echo makes it easier to build and use. In Echo, middleware is simply a function that takes echo.HandlerFunc and returns another echo.HandlerFunc function. Echo provides a vast amount of power with this simple abstraction, but let’s start by looking at something simple:
e := echo.New()
e.Use(middleware.Logger())
Here, we are adding a logger to our requests that returns something like this for each request:
{"time":"2025-07-03T22:55:44.848741244+02:00","id":"","remote_ip":"127.0.0.1","host":"localhost:8080","method":"GET","uri":"/","user_agent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0","status":200,"error":"","latency":54753,"latency_human":"...