好像有戏
This commit is contained in:
35
srv/internal/route/register.go
Normal file
35
srv/internal/route/register.go
Normal file
@@ -0,0 +1,35 @@
|
||||
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}
|
||||
}
|
||||
Reference in New Issue
Block a user