-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (47 loc) · 1.35 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
package main
import (
"High-Performance-Online-Bookstore/config"
"High-Performance-Online-Bookstore/database"
"High-Performance-Online-Bookstore/permission"
ver "High-Performance-Online-Bookstore/pkg/version"
"High-Performance-Online-Bookstore/router"
"github.com/spf13/pflag"
"go.uber.org/zap"
)
var (
cfg = pflag.StringP("config", "c", "", "Specify config file path.")
version = pflag.BoolP("version", "v", false, "show version info.")
logger *zap.Logger
)
// @title High-Performance-Online-Bookstore
// @version 0.7.0
// @description The jinshuzhai bookstore api server.
// @termsOfService https://github.com/zouyonghe
// @contact.name API Support
// @contact.url https://github.com/zouyonghe
// @contact.email [email protected]
// @license.name GPLv3
// @license.url https://www.gnu.org/licenses/gpl-3.0.html
// @host 127.0.0.1:8081
// @BasePath /v1
// @Schemes http https
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
func main() {
// parse command line arguments
pflag.Parse()
// show version info
ver.CheckShowVersion(*version)
// initialize config
logger = config.Init(*cfg)
// Replace global logger
gl := zap.ReplaceGlobals(logger)
defer gl()
// initialize gorm
database.Init()
// initialize RBAC
permission.Init()
// initialize router
router.Init()
}