-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (28 loc) · 789 Bytes
/
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
package main
import (
"github.com/bagus123/go-rest-mongodb/daos"
adminRouter "github.com/bagus123/go-rest-mongodb/routers/v1/admin"
apiRouter "github.com/bagus123/go-rest-mongodb/routers/v1/api"
"github.com/bagus123/go-rest-mongodb/seeds"
"github.com/gin-gonic/contrib/static"
"github.com/gin-gonic/gin"
)
func main() {
// init DAO
daos.InitDAO()
// running user seed
seeds.RunUserSeed()
router := gin.Default()
router.Use(static.Serve("/", static.LocalFile("./public", true)))
router.NoRoute(noRouteHandler())
apiV1 := router.Group("/v1/api")
adminV1 := router.Group("/v1/admin")
apiRouter.Init(apiV1)
adminRouter.Init(adminV1)
router.Run(":8080")
}
func noRouteHandler() gin.HandlerFunc {
return func(c *gin.Context) {
c.JSON(404, "Page Not Found")
}
}