2025-02-12 19:29:00 +01:00
|
|
|
package apis
|
|
|
|
|
|
|
|
|
|
import (
|
2025-04-16 23:24:23 +02:00
|
|
|
"database/sql"
|
2025-02-12 19:29:00 +01:00
|
|
|
"errors"
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
)
|
|
|
|
|
|
2025-04-16 23:24:23 +02:00
|
|
|
var db *sql.DB
|
2025-02-12 19:29:00 +01:00
|
|
|
|
2025-04-16 23:24:23 +02:00
|
|
|
func BindAPIs(r *gin.Engine, cfg_db *sql.DB) error {
|
2025-02-12 19:29:00 +01:00
|
|
|
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)
|
2025-04-09 18:37:02 +02:00
|
|
|
bindExpensesAPIs(r)
|
2025-02-12 19:29:00 +01:00
|
|
|
return nil
|
|
|
|
|
}
|