A middleware wraps an HTTP request to add additional logic before or after the request has been handled. A middleware can be any struct that implements the chttp.Middleware interface.
type Middleware interface {
Handle(next http.Handler) http.Handler
}
If you have a simple function, you can use the chttp.HandleMiddleware function to create a middleware out of it.
Request Logger Middleware
This is an example middleware that logs each incoming HTTP request.
In pkg/app/handler.go, you can pass a list of middlewares to the chttp.NewHandler function. These middlewares will be executed on all requests handled by this handler.