Files
gf/.example/net/ghttp/server/resource/resource.go

30 lines
571 B
Go
Raw Normal View History

2019-08-14 22:03:52 +08:00
package main
import (
"fmt"
2019-08-14 22:03:52 +08:00
"github.com/gogf/gf/frame/g"
2019-08-16 00:29:14 +08:00
"github.com/gogf/gf/net/ghttp"
2019-08-14 22:03:52 +08:00
"github.com/gogf/gf/os/gres"
_ "github.com/gogf/gf/os/gres/testdata/data"
2019-08-14 22:03:52 +08:00
)
func main() {
gres.Dump()
2019-10-31 23:37:33 +08:00
//v := g.View()
//v.SetPath("template/layout1")
2019-08-16 00:29:14 +08:00
2019-08-14 22:03:52 +08:00
s := g.Server()
s.SetIndexFolder(true)
s.SetServerRoot("root")
s.BindHookHandler("/*", ghttp.HOOK_BEFORE_SERVE, func(r *ghttp.Request) {
fmt.Println(r.URL.Path, r.IsFileRequest())
})
2019-08-16 00:29:14 +08:00
s.BindHandler("/template", func(r *ghttp.Request) {
2019-10-31 23:37:33 +08:00
r.Response.WriteTpl("layout1/layout.html")
2019-08-16 00:29:14 +08:00
})
2019-10-31 23:37:33 +08:00
s.SetPort(8198)
2019-08-14 22:03:52 +08:00
s.Run()
}