requestLogger is a middleware that logs each request method and path. It runs for every route registered on the group it is attached to.
()
| 52 | // requestLogger is a middleware that logs each request method and path. |
| 53 | // It runs for every route registered on the group it is attached to. |
| 54 | func requestLogger() pine.Middleware { |
| 55 | return func(next pine.Handler) pine.Handler { |
| 56 | return func(c *pine.Ctx) error { |
| 57 | log.Printf("%s %s", c.Method, c.BaseURI) |
| 58 | return next(c) |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // requireAPIKey checks for a valid X-API-Key header. |
| 64 | // Attach it to a group to gate an entire sub-tree without touching each handler. |