Skip to content

Commit e9aa845

Browse files
committed
feat: added GetPath, GetService, GetValidator and GetController methods to the Module interface and implementation
1 parent 59b12d1 commit e9aa845

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

http/factory/module.go

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,72 @@ import (
88
type (
99
// ModuleWrapper is the interface for the route module
1010
ModuleWrapper interface {
11-
Create(baseRouter gonethttproute.RouterWrapper, path string) error
11+
Create(baseRouter gonethttproute.RouterWrapper) error
1212
GetRouter() gonethttproute.RouterWrapper
1313
Handler() http.Handler
14+
GetService() ServiceWrapper
15+
GetValidator() ValidatorWrapper
16+
GetController() ControllerWrapper
17+
GetPath() string
1418
}
1519

1620
// Module is the struct for the route module
1721
Module struct {
18-
Service ServiceWrapper
19-
Validator ValidatorWrapper
20-
Controller ControllerWrapper
22+
path string
23+
service ServiceWrapper
24+
validator ValidatorWrapper
25+
controller ControllerWrapper
2126
}
2227
)
2328

2429
// NewModule is a function that creates a new instance of the Module struct
2530
func NewModule(
31+
path string,
2632
service ServiceWrapper,
2733
validator ValidatorWrapper,
2834
controller ControllerWrapper,
2935
) ModuleWrapper {
3036
return &Module{
31-
Service: service,
32-
Validator: validator,
33-
Controller: controller,
37+
path: path,
38+
service: service,
39+
validator: validator,
40+
controller: controller,
3441
}
3542
}
3643

3744
// Create is a function that creates a new instance of the Module struct
3845
func (m *Module) Create(
3946
baseRouter gonethttproute.RouterWrapper,
40-
path string,
4147
) error {
42-
return m.Controller.CreateRouter(baseRouter, path)
48+
return m.controller.CreateRouter(baseRouter, m.path)
4349
}
4450

4551
// GetRouter is a function that returns the router
4652
func (m *Module) GetRouter() gonethttproute.RouterWrapper {
47-
return m.Controller.GetRouter()
53+
return m.controller.GetRouter()
4854
}
4955

5056
// Handler is a function that returns the handler
5157
func (m *Module) Handler() http.Handler {
52-
return m.Controller.Handler()
58+
return m.controller.Handler()
59+
}
60+
61+
// GetPath is a function that returns the path
62+
func (m *Module) GetPath() string {
63+
return m.path
64+
}
65+
66+
// GetService is a function that returns the service
67+
func (m *Module) GetService() ServiceWrapper {
68+
return m.service
69+
}
70+
71+
// GetValidator is a function that returns the validator
72+
func (m *Module) GetValidator() ValidatorWrapper {
73+
return m.validator
74+
}
75+
76+
// GetController is a function that returns the controller
77+
func (m *Module) GetController() ControllerWrapper {
78+
return m.controller
5379
}

0 commit comments

Comments
 (0)