Files
Crimson-Gatekeeper/srv/internal/route/register.go

36 lines
569 B
Go
Raw Normal View History

2026-01-22 00:12:24 +08:00
package route
import (
"Crimson-Gatekeeper/internal/query"
"net/http"
"github.com/gin-gonic/gin"
)
type Controller interface {
register(gin *gin.Engine)
}
func RegCtrl(cs []Controller) {
route := gin.Default()
for _, ctrl := range cs {
ctrl.register(route)
}
http.Handle("/", route)
}
type TestBoot struct {
c *query.Query
}
func (t *TestBoot) Run() error {
http.HandleFunc("/echo", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello world!"))
})
return nil
}
func NewTestBoot(q *query.Query) *TestBoot {
return &TestBoot{q}
}