github.com/gogf/gf@v1.16.9/.example/net/ghttp/server/static/static_path.go (about) 1 package main 2 3 import "github.com/gogf/gf/frame/g" 4 5 // 静态文件服务器,支持自定义静态目录映射 6 func main() { 7 s := g.Server() 8 s.SetIndexFolder(true) 9 s.SetServerRoot("/Users/john/Temp") 10 s.AddSearchPath("/Users/john/Documents") 11 s.AddStaticPath("/my-doc", "/Users/john/Documents") 12 s.SetPort(8199) 13 s.Run() 14 }