mirror of
https://gitee.com/johng/gf
synced 2026-07-04 04:52:48 +08:00
26 lines
926 B
Go
26 lines
926 B
Go
package main
|
|
|
|
import (
|
|
"gitee.com/johng/gf/g"
|
|
"gitee.com/johng/gf/g/os/glog"
|
|
"gitee.com/johng/gf/g/net/ghttp"
|
|
)
|
|
|
|
func main() {
|
|
// 基本事件回调使用
|
|
p := "/:name/info/{uid}"
|
|
s := g.Server()
|
|
s.BindHookHandlerByMap(p, map[string]ghttp.HandlerFunc{
|
|
"BeforeServe" : func(r *ghttp.Request){ glog.Println("BeforeServe") },
|
|
"AfterServe" : func(r *ghttp.Request){ glog.Println("AfterServe") },
|
|
"BeforeOutput" : func(r *ghttp.Request){ glog.Println("BeforeOutput") },
|
|
"AfterOutput" : func(r *ghttp.Request){ glog.Println("AfterOutput") },
|
|
"BeforeClose" : func(r *ghttp.Request){ glog.Println("BeforeClose") },
|
|
"AfterClose" : func(r *ghttp.Request){ glog.Println("AfterClose") },
|
|
})
|
|
s.BindHandler(p, func(r *ghttp.Request) {
|
|
r.Response.Write("用户:", r.Get("name"), ", uid:", r.Get("uid"))
|
|
})
|
|
s.SetPort(8199)
|
|
s.Run()
|
|
} |