example&comment update

This commit is contained in:
John Guo
2021-11-01 19:46:39 +08:00
parent c0c68d1e46
commit 79a233eb78
14 changed files with 43 additions and 36 deletions

View File

@ -16,10 +16,10 @@ func main() {
})
s.BindHookHandlerByMap(p, map[string]ghttp.HandlerFunc{
ghttp.HookBeforeServe: func(r *ghttp.Request) {
glog.To(r.Response.Writer).Print("BeforeServe")
glog.To(r.Response.Writer).Print(r.Context(), "BeforeServe")
},
ghttp.HookAfterServe: func(r *ghttp.Request) {
glog.To(r.Response.Writer).Print("AfterServe")
glog.To(r.Response.Writer).Print(r.Context(), "AfterServe")
},
})
s.SetPort(8199)

View File

@ -10,7 +10,7 @@ func main() {
s1 := ghttp.GetServer("s1")
s1.SetPort(8882)
s1.BindHandler("/", func(r *ghttp.Request) {
glog.Print("s1")
glog.Print(r.Context(), "s1")
r.Response.Writeln("s1")
})
s1.Start()
@ -18,7 +18,7 @@ func main() {
s2 := ghttp.GetServer("s2")
s2.SetPort(8882)
s2.BindHandler("/", func(r *ghttp.Request) {
glog.Print("s2")
glog.Print(r.Context(), "s2")
r.Response.Writeln("s2")
})
s2.Start()