2018-11-06 18:53:25 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2019-07-29 21:01:19 +08:00
|
|
|
"github.com/gogf/gf/frame/g"
|
|
|
|
|
"github.com/gogf/gf/net/ghttp"
|
|
|
|
|
"github.com/gogf/gf/os/glog"
|
2018-11-06 18:53:25 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
2019-04-03 00:03:46 +08:00
|
|
|
p := "/"
|
|
|
|
|
s := g.Server()
|
|
|
|
|
s.BindHandler(p, func(r *ghttp.Request) {
|
|
|
|
|
r.Response.Writeln("start")
|
|
|
|
|
r.Exit()
|
|
|
|
|
r.Response.Writeln("end")
|
|
|
|
|
})
|
|
|
|
|
s.BindHookHandlerByMap(p, map[string]ghttp.HandlerFunc{
|
|
|
|
|
ghttp.HOOK_BEFORE_SERVE: func(r *ghttp.Request) {
|
|
|
|
|
glog.To(r.Response.Writer).Println("BeforeServe")
|
|
|
|
|
},
|
|
|
|
|
ghttp.HOOK_AFTER_SERVE: func(r *ghttp.Request) {
|
|
|
|
|
glog.To(r.Response.Writer).Println("AfterServe")
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
s.SetPort(8199)
|
|
|
|
|
s.Run()
|
|
|
|
|
}
|