Skip to content

Commit

Permalink
feat: added load function to the Module interface and implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ralvarezdev committed Jan 25, 2025
1 parent c473d56 commit b23a1ee
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion http/factory/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type (
GetValidator() ValidatorWrapper
GetController() ControllerWrapper
GetPath() string
GetLoadFn() func()
GetSubmodules() *[]ModuleWrapper
}

Expand All @@ -24,6 +25,7 @@ type (
service ServiceWrapper
validator ValidatorWrapper
controller ControllerWrapper
loadFn func()
submodules []ModuleWrapper
}
)
Expand All @@ -34,18 +36,20 @@ func NewModule(
service ServiceWrapper,
validator ValidatorWrapper,
controller ControllerWrapper,
loadFn func(),
submodules ...ModuleWrapper,
) ModuleWrapper {
return &Module{
path: path,
service: service,
validator: validator,
controller: controller,
loadFn: loadFn,
submodules: submodules,
}
}

// Create is a function that creates the router for the controller and its submodules
// Create is a function that creates the router for the controller and its submodules, and loads the module
func (m *Module) Create(
baseRouter gonethttproute.RouterWrapper,
) error {
Expand All @@ -61,6 +65,9 @@ func (m *Module) Create(
return err
}
}

// Load the module
m.loadFn()
return nil
}

Expand Down Expand Up @@ -94,6 +101,11 @@ func (m *Module) GetController() ControllerWrapper {
return m.controller
}

// GetLoadFn is a function that returns the load function
func (m *Module) GetLoadFn() func() {
return m.loadFn
}

// GetSubmodules is a function that returns the submodules
func (m *Module) GetSubmodules() *[]ModuleWrapper {
return &m.submodules
Expand Down

0 comments on commit b23a1ee

Please sign in to comment.