github.com/gogf/gf@v1.16.9/.example/net/ghttp/server/resource/resource.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/gogf/gf/frame/g" 7 "github.com/gogf/gf/net/ghttp" 8 "github.com/gogf/gf/os/gres" 9 _ "github.com/gogf/gf/os/gres/testdata/data" 10 ) 11 12 func main() { 13 gres.Dump() 14 15 //v := g.View() 16 //v.SetPath("template/layout1") 17 18 s := g.Server() 19 s.SetIndexFolder(true) 20 s.SetServerRoot("root") 21 s.BindHookHandler("/*", ghttp.HookBeforeServe, func(r *ghttp.Request) { 22 fmt.Println(r.URL.Path, r.IsFileRequest()) 23 }) 24 s.BindHandler("/template", func(r *ghttp.Request) { 25 r.Response.WriteTpl("layout1/layout.html") 26 }) 27 s.SetPort(8198) 28 s.Run() 29 }