package main
import (
"github.com/gogf/gf/v2/container/gtype"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)
type Controller struct {
total *gtype.Int
}
func (c *Controller) Total(r *ghttp.Request) {
r.Response.Write("total:", c.total.Add(1))
}
func main() {
s := g.Server()
c := &Controller{
total: gtype.NewInt(),
}
s.BindHandler("/total", c.Total)
s.SetPort(8199)
s.Run()
}
3 Comments
qingtian009
有注册路由,为何没有注销路由
wongxy
有啥场景需要注销路由?
sersoong
如果有一份经常变动的路由列表配置,我怎么在s.Run()之后重新s.BindHandler注册路由呢?也就是说,如何动态的注册可能变化的路由