-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
32 lines (28 loc) · 790 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
_ "gf-api/boot"
"gf-api/common"
_ "gf-api/router"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/swagger"
)
// @title `gf-api` 基于 GF(Go Frame) api demo
// @version 1.0
// @description `gf-api` api demo 接口文档。
// @schemes http https
func main() {
err := gtime.SetTimeZone("Asia/Shanghai")
if err != nil {
panic(err)
}
server := g.Server()
server.BindStatusHandlerByMap(map[int]ghttp.HandlerFunc{
403: func(r *ghttp.Request) { common.JsonExit(r, common.Forbid) },
404: func(r *ghttp.Request) { common.JsonExit(r, common.NoRoute) },
500: func(r *ghttp.Request) { common.JsonExit(r, common.SystemError) },
})
server.Plugin(&swagger.Swagger{})
server.Run()
}