forked from GoAdminGroup/go-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (51 loc) · 1.31 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
package main
import (
"github.com/gin-gonic/gin"
"github.com/chenhg5/go-admin/engine"
"github.com/chenhg5/go-admin/examples/datamodel"
"github.com/chenhg5/go-admin/modules/config"
"github.com/chenhg5/go-admin/plugins/admin"
"github.com/chenhg5/go-admin/plugins/example"
"github.com/chenhg5/go-admin/template/types"
_ "github.com/chenhg5/go-admin/adapter/gin"
)
func main() {
r := gin.Default()
eng := engine.Default()
cfg := config.Config{
DATABASE: []config.Database{
{
HOST: "127.0.0.1",
PORT: "3306",
USER: "root",
PWD: "root",
NAME: "godmin",
MAX_IDLE_CON: 50,
MAX_OPEN_CON: 150,
DRIVER: "mysql",
},
},
DOMAIN: "localhost",
PREFIX: "admin",
STORE: config.Store{
PATH: "./uploads",
PREFIX: "uploads",
},
LANGUAGE: "cn",
INDEX: "/",
}
adminPlugin := admin.NewAdmin(datamodel.Generators)
// you can custom a plugin like:
examplePlugin := example.NewExample()
if err := eng.AddConfig(cfg).AddPlugins(adminPlugin, examplePlugin).Use(r); err != nil {
panic(err)
}
r.Static("/uploads", "./uploads")
// you can custom your pages like:
r.GET("/"+cfg.PREFIX+"/custom", func(ctx *gin.Context) {
engine.Content(ctx, func() types.Panel {
return datamodel.GetContent()
})
})
r.Run(":9033")
}