Files
inventory-plus-plus/internal/server/response/handler.go
T
2026-01-13 22:07:20 -07:00

23 lines
340 B
Go

package response
import (
"github.com/gin-gonic/gin"
)
type (
HandlerFunc = func(c *gin.Context) (Response, error)
Middleware = func(HandlerFunc) HandlerFunc
)
func Handler(f HandlerFunc) gin.HandlerFunc {
return func(c *gin.Context) {
res, err := f(c)
if err != nil {
WriteError(c, err)
} else {
Write(c, res)
}
}
}