API package refactor

This commit is contained in:
Manuel Forcén Muñoz 2025-02-12 19:29:00 +01:00
parent a7cd86962e
commit bc6b57bc54
14 changed files with 474 additions and 416 deletions

27
apis/base.go Normal file
View file

@ -0,0 +1,27 @@
package apis
import (
"errors"
"net/http"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
var db *gorm.DB
func BindAPIs(r *gin.Engine, cfg_db *gorm.DB) error {
if cfg_db == nil {
return errors.New("Database is null")
}
db = cfg_db
r.GET("/", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "pong",
})
})
bindPlanAPIs(r)
bindPollAPIs(r)
bindUserAPIs(r)
return nil
}