feat(backend): module scaffold, config, gin router with healthz

This commit is contained in:
2026-09-04 23:39:31 +08:00
parent 2458c9ca4d
commit ad934d9812
5 changed files with 238 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
package api
import (
"net/http"
"github.com/gin-gonic/gin"
"booklib/internal/config"
)
type api struct {
cfg *config.Config
// st, rdb, sc 字段在 Task 4/9 加入
}
func NewRouter(cfg *config.Config) *gin.Engine {
gin.SetMode(gin.ReleaseMode)
_ = &api{cfg: cfg} // Task 4/9 起此处为 a := &api{...},handler 挂在 a 上
r := gin.New()
r.Use(gin.Recovery())
g := r.Group("/api")
g.GET("/healthz", func(c *gin.Context) { c.String(http.StatusOK, "ok") })
return r
}