API package refactor
This commit is contained in:
parent
a7cd86962e
commit
bc6b57bc54
14 changed files with 474 additions and 416 deletions
27
apis/base.go
Normal file
27
apis/base.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue