Files
gf/.example/net/ghttp/server/reload/simple.go
2021-10-11 21:41:56 +08:00

28 lines
535 B
Go

package main
import (
"time"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gproc"
)
func main() {
s := g.Server()
s.BindHandler("/", func(r *ghttp.Request) {
r.Response.Writeln("哈喽!")
})
s.BindHandler("/pid", func(r *ghttp.Request) {
r.Response.Writeln(gproc.Pid())
})
s.BindHandler("/sleep", func(r *ghttp.Request) {
r.Response.Writeln(gproc.Pid())
time.Sleep(10 * time.Second)
r.Response.Writeln(gproc.Pid())
})
s.EnableAdmin()
s.SetPort(8199)
s.Run()
}