2019-08-14 22:03:52 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2019-09-06 17:59:55 +08:00
|
|
|
"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"
|
2019-09-06 17:59:55 +08:00
|
|
|
_ "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)
|
2019-09-06 17:59:55 +08:00
|
|
|
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()
|
|
|
|
|
}
|