-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
66 lines (52 loc) · 1.41 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
lang "github.com/gin-contrib/i18n"
"github.com/gin-gonic/gin"
"golang.org/x/text/language"
"gopkg.in/yaml.v3"
"message/config"
"message/database"
"message/logs"
"message/router"
"message/utils"
)
// @title 消息系统 API
// @version 1.0
// @description 简单又好用的消息服务。快来给你"项目"添加消息功能。
// @termsOfService https://github.com/webb-l
// @contact.name Webb
// @contact.url https://github.com/webb-l
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:1204
// @BasePath /
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
// @externalDocs.description OpenAPI
// @externalDocs.url https://swagger.io/resources/open-api/
func main() {
// 初始化Gin引擎
r := gin.Default()
// 初始化配置
config.InitConfig()
// 初始日志
logs.InitLog()
defer logs.Sync()
r.Use(utils.AccessLogger())
// 国际化中间件
r.Use(lang.Localize(lang.WithBundle(&lang.BundleCfg{
DefaultLanguage: language.Chinese,
FormatBundleFile: "yaml",
AcceptLanguage: []language.Tag{language.Chinese, language.English},
RootPath: "resources/lang",
UnmarshalFunc: yaml.Unmarshal,
})))
// 初始化路由
router.InitRouter(r)
// 连接MySQL数据库
database.InitMySQL()
// 启动Gin引擎
r.Run(":1204")
}