Files
gf/.example/net/ghttp/server/status_map.go
2021-10-11 21:41:56 +08:00

18 lines
393 B
Go

package main
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)
func main() {
s := g.Server()
s.BindStatusHandlerByMap(map[int]ghttp.HandlerFunc{
403: func(r *ghttp.Request) { r.Response.Writeln("403") },
404: func(r *ghttp.Request) { r.Response.Writeln("404") },
500: func(r *ghttp.Request) { r.Response.Writeln("500") },
})
s.SetPort(8199)
s.Run()
}