/
module.go
23 lines (19 loc) · 996 Bytes
/
module.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package user
import (
"github.com/gin-gonic/gin"
"gopkg.in/go-playground/validator.v9"
"gorm.io/gorm"
hashApplication "github.com/PacktPublishing/Domain-Driven-Design-with-Go/chapter5/internal/hash/application"
"github.com/PacktPublishing/Domain-Driven-Design-with-Go/chapter5/internal/user/application"
"github.com/PacktPublishing/Domain-Driven-Design-with-Go/chapter5/internal/user/infrastructure"
"github.com/PacktPublishing/Domain-Driven-Design-with-Go/chapter5/internal/user/presentation"
)
// Module is a struct that defines all dependencies inside user module
type Module struct{}
// Configure setups all dependencies
func (m *Module) Configure(db *gorm.DB, engine *gin.Engine, validate *validator.Validate, service hashApplication.HashService) {
repository := infrastructure.NewUserRepository(db)
useCase := application.NewRegistrationUseCase(repository)
controller := presentation.NewUserController(useCase, validate, service)
engine.POST("/users", controller.Register)
}