forked from 1340691923/xwl_bi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.go
65 lines (56 loc) · 1.25 KB
/
index.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
//路由层
package router
import (
. "github.com/1340691923/xwl_bi/controller"
. "github.com/1340691923/xwl_bi/middleware"
"github.com/1340691923/xwl_bi/views"
. "github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/compress"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/filesystem"
"github.com/gofiber/fiber/v2/middleware/pprof"
jsoniter "github.com/json-iterator/go"
)
func Init() *App {
var json = jsoniter.ConfigCompatibleWithStandardLibrary
app := New(Config{
AppName: "铸龙-BI",
JSONDecoder: json.Unmarshal,
JSONEncoder: json.Marshal,
})
app.Use(compress.New(compress.Config{
Level: compress.LevelBestCompression,
}))
app.Use("/", filesystem.New(filesystem.Config{
Root: views.GetFileSystem(),
}))
app.Use(
cors.New(),
pprof.New(),
)
app.Post("/api/gm_user/login", ManagerUserController{}.Login)
routerWebsocket(app)
app.Use(
Timer,
JwtMiddleware,
Rbac,
)
return runRouterGroupFn(
app,
runOperaterLog,
runGmUser,
runRealData,
runMetaData,
runAnalysis,
runPannel,
runApp,
runUserGroup,
)
}
type routerGroupFn func(app *App)
func runRouterGroupFn(app *App, fns ...routerGroupFn) *App {
for _, fn := range fns {
fn(app)
}
return app
}