github.com/gogf/gf@v1.16.9/.example/net/ghttp/server/name.go (about) 1 package main 2 3 import ( 4 "github.com/gogf/gf/frame/g" 5 "github.com/gogf/gf/net/ghttp" 6 ) 7 8 type User struct{} 9 10 func (u *User) ShowList(r *ghttp.Request) { 11 r.Response.Write("list") 12 } 13 14 func main() { 15 s1 := g.Server(1) 16 s2 := g.Server(2) 17 s3 := g.Server(3) 18 s4 := g.Server(4) 19 20 s1.SetNameToUriType(ghttp.URI_TYPE_DEFAULT) 21 s2.SetNameToUriType(ghttp.URI_TYPE_FULLNAME) 22 s3.SetNameToUriType(ghttp.URI_TYPE_ALLLOWER) 23 s4.SetNameToUriType(ghttp.URI_TYPE_CAMEL) 24 25 s1.BindObject("/{.struct}/{.method}", new(User)) 26 s2.BindObject("/{.struct}/{.method}", new(User)) 27 s3.BindObject("/{.struct}/{.method}", new(User)) 28 s4.BindObject("/{.struct}/{.method}", new(User)) 29 30 s1.SetPort(8100) 31 s2.SetPort(8200) 32 s3.SetPort(8300) 33 s4.SetPort(8400) 34 35 s1.Start() 36 s2.Start() 37 s3.Start() 38 s4.Start() 39 40 g.Wait() 41 }