feat: added first api route

This commit is contained in:
2026-02-18 08:32:27 -05:00
parent e1f0a638b9
commit 150f95ee0b
6 changed files with 149 additions and 18 deletions

View File

@@ -0,0 +1,33 @@
package middleware
import (
"time"
"github.com/charmbracelet/log"
"github.com/labstack/echo/v5"
)
func ServerHandler(next echo.HandlerFunc) echo.HandlerFunc {
return func(c *echo.Context) error {
start := time.Now()
// Process the request
err := next(c)
if err != nil {
c.Logger().Error(err.Error())
}
stop := time.Now()
req := c.Request()
// Log using charmbracelet
log.Info("Request handled",
"method", req.Method,
"path", req.URL.Path,
"latency", stop.Sub(start),
"ip", c.RealIP(),
)
return nil
}
}