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

20 lines
384 B
Go
Raw Normal View History

2017-12-31 18:18:00 +08:00
package main
2019-07-29 21:01:19 +08:00
import "github.com/gogf/gf/net/ghttp"
2017-12-31 18:18:00 +08:00
func Hello1(r *ghttp.Request) {
2019-04-03 00:03:46 +08:00
r.Response.Write("127.0.0.1: Hello World1!")
2017-12-31 18:18:00 +08:00
}
func Hello2(r *ghttp.Request) {
2019-04-03 00:03:46 +08:00
r.Response.Write("localhost: Hello World2!")
2017-12-31 18:18:00 +08:00
}
func main() {
2019-04-03 00:03:46 +08:00
s := ghttp.GetServer()
s.Domain("127.0.0.1").BindHandler("/", Hello1)
s.Domain("localhost, local").BindHandler("/", Hello2)
s.SetPort(8199)
s.Run()
2017-12-31 18:18:00 +08:00
}