forked from GoAdminGroup/go-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (42 loc) · 1.07 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
package main
import (
"github.com/buaazp/fasthttprouter"
"github.com/valyala/fasthttp"
_ "github.com/chenhg5/go-admin/adapter/fasthttp"
"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"
)
func main() {
router := fasthttprouter.New()
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",
INDEX: "/",
}
adminPlugin := admin.NewAdmin(datamodel.Generators)
examplePlugin := example.NewExample()
if err := eng.AddConfig(cfg).AddPlugins(adminPlugin, examplePlugin).Use(router); err != nil {
panic(err)
}
var waitChan chan int
go func() {
fasthttp.ListenAndServe(":8897", router.Handler)
}()
<-waitChan
}