github.com/gogf/gf@v1.16.9/.example/net/ghttp/server/status_map.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 func main() { 9 s := g.Server() 10 s.BindStatusHandlerByMap(map[int]ghttp.HandlerFunc{ 11 403: func(r *ghttp.Request) { r.Response.Writeln("403") }, 12 404: func(r *ghttp.Request) { r.Response.Writeln("404") }, 13 500: func(r *ghttp.Request) { r.Response.Writeln("500") }, 14 }) 15 s.SetPort(8199) 16 s.Run() 17 }