feat(backend): rouage gin /api/v1, enveloppe {data,meta}/{error}, health réel, stubs 501 + test de contrat routes

This commit is contained in:
m
2026-09-10 07:16:57 +02:00
parent 837bfa8a12
commit bdf1fadce9
13 changed files with 193 additions and 28 deletions
+32
View File
@@ -0,0 +1,32 @@
package api
import "github.com/gin-gonic/gin"
const NotImplementedCode = "NOT_IMPLEMENTED"
type Meta struct {
Page int `json:"page"`
PageSize int `json:"pageSize"`
Total int `json:"total"`
}
func OK(c *gin.Context, data any) {
c.JSON(200, gin.H{"data": data})
}
func OKList(c *gin.Context, data any, page, pageSize, total int) {
c.JSON(200, gin.H{
"data": data,
"meta": Meta{Page: page, PageSize: pageSize, Total: total},
})
}
func Error(c *gin.Context, status int, code, message string) {
c.JSON(status, gin.H{
"error": gin.H{"code": code, "message": message},
})
}
func NotImplemented(c *gin.Context) {
Error(c, 501, NotImplementedCode, "route not implemented yet")
}