Skip to content

Commit

Permalink
feat: added GetPath, GetService, GetValidator and GetController metho…
Browse files Browse the repository at this point in the history
…ds to the Module interface and implementation
  • Loading branch information
ralvarezdev committed Jan 25, 2025
1 parent 59b12d1 commit e9aa845
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions http/factory/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,72 @@ import (
type (
// ModuleWrapper is the interface for the route module
ModuleWrapper interface {
Create(baseRouter gonethttproute.RouterWrapper, path string) error
Create(baseRouter gonethttproute.RouterWrapper) error
GetRouter() gonethttproute.RouterWrapper
Handler() http.Handler
GetService() ServiceWrapper
GetValidator() ValidatorWrapper
GetController() ControllerWrapper
GetPath() string
}

// Module is the struct for the route module
Module struct {
Service ServiceWrapper
Validator ValidatorWrapper
Controller ControllerWrapper
path string
service ServiceWrapper
validator ValidatorWrapper
controller ControllerWrapper
}
)

// NewModule is a function that creates a new instance of the Module struct
func NewModule(
path string,
service ServiceWrapper,
validator ValidatorWrapper,
controller ControllerWrapper,
) ModuleWrapper {
return &Module{
Service: service,
Validator: validator,
Controller: controller,
path: path,
service: service,
validator: validator,
controller: controller,
}
}

// Create is a function that creates a new instance of the Module struct
func (m *Module) Create(
baseRouter gonethttproute.RouterWrapper,
path string,
) error {
return m.Controller.CreateRouter(baseRouter, path)
return m.controller.CreateRouter(baseRouter, m.path)
}

// GetRouter is a function that returns the router
func (m *Module) GetRouter() gonethttproute.RouterWrapper {
return m.Controller.GetRouter()
return m.controller.GetRouter()
}

// Handler is a function that returns the handler
func (m *Module) Handler() http.Handler {
return m.Controller.Handler()
return m.controller.Handler()
}

// GetPath is a function that returns the path
func (m *Module) GetPath() string {
return m.path
}

// GetService is a function that returns the service
func (m *Module) GetService() ServiceWrapper {
return m.service
}

// GetValidator is a function that returns the validator
func (m *Module) GetValidator() ValidatorWrapper {
return m.validator
}

// GetController is a function that returns the controller
func (m *Module) GetController() ControllerWrapper {
return m.controller
}

0 comments on commit e9aa845

Please sign in to comment.