forked from engineerit2014/ms-gin-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.go
34 lines (28 loc) · 831 Bytes
/
router.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
package router
import (
"github.com/gin-gonic/gin"
"github.com/laironacosta/ms-gin-go/controllers"
)
type Router struct {
server *gin.Engine
userController controllers.UserControllerInterface
}
func NewRouter(server *gin.Engine, userController controllers.UserControllerInterface) *Router {
return &Router{
server,
userController,
}
}
func (r *Router) Init() {
//create a default router with default middleware
basePath := r.server.Group("/ms-gin-go")
basePath.GET("/health", controllers.Health)
users := basePath.Group("/users")
{
users.POST("/", r.userController.Create)
users.GET("/:email", r.userController.GetByEmail)
users.PUT("/:email", r.userController.UpdateByEmail)
users.PATCH("/:email", r.userController.UpdateByEmail)
users.DELETE("/:email", r.userController.DeleteByEmail)
}
}