@@ -24,34 +24,17 @@ type (
2424
2525 // Module is the struct for the route module
2626 Module struct {
27- path string
28- service interface {}
29- validator interface {}
30- controller interface {}
31- loadFn func ()
32- registerRoutesFn func ()
33- submodules []ModuleWrapper
27+ Path string
28+ Service interface {}
29+ Validator interface {}
30+ Controller interface {}
31+ LoadFn func ()
32+ RegisterRoutesFn func ()
33+ Submodules []ModuleWrapper
3434 gonethttproute.RouterWrapper
3535 }
3636)
3737
38- // NewModule is a function that creates a new instance of the Module struct
39- func NewModule (
40- path string ,
41- service ,
42- validator ,
43- controller interface {},
44- submodules ... ModuleWrapper ,
45- ) ModuleWrapper {
46- return & Module {
47- path : path ,
48- service : service ,
49- validator : validator ,
50- controller : controller ,
51- submodules : submodules ,
52- }
53- }
54-
5538// Create is a function that creates the router for the controller and its submodules, and loads the module
5639func (m * Module ) Create (
5740 baseRouter gonethttproute.RouterWrapper ,
@@ -62,24 +45,24 @@ func (m *Module) Create(
6245 }
6346
6447 // Set the base route
65- m .RouterWrapper = baseRouter .NewGroup (m .path )
48+ m .RouterWrapper = baseRouter .NewGroup (m .Path )
6649
6750 // Register the routes
68- if m .registerRoutesFn != nil {
69- m .registerRoutesFn ()
51+ if m .RegisterRoutesFn != nil {
52+ m .RegisterRoutesFn ()
7053 }
7154
7255 // Create the submodules controllers router
7356 router := m .GetRouter ()
74- for _ , submodule := range m .submodules {
57+ for _ , submodule := range m .Submodules {
7558 if err := submodule .Create (router ); err != nil {
7659 return err
7760 }
7861 }
7962
8063 // Load the module
81- if m .loadFn != nil {
82- m .loadFn ()
64+ if m .LoadFn != nil {
65+ m .LoadFn ()
8366 }
8467 return nil
8568}
@@ -96,40 +79,30 @@ func (m *Module) Handler() http.Handler {
9679
9780// GetPath is a function that returns the path
9881func (m * Module ) GetPath () string {
99- return m .path
82+ return m .Path
10083}
10184
10285// GetService is a function that returns the service
10386func (m * Module ) GetService () interface {} {
104- return m .service
87+ return m .Service
10588}
10689
10790// GetValidator is a function that returns the validator
10891func (m * Module ) GetValidator () interface {} {
109- return m .validator
92+ return m .Validator
11093}
11194
11295// GetController is a function that returns the controller
11396func (m * Module ) GetController () interface {} {
114- return m .controller
115- }
116-
117- // SetLoadFn is a function that sets the load function
118- func (m * Module ) SetLoadFn (loadFn func ()) {
119- m .loadFn = loadFn
97+ return m .Controller
12098}
12199
122100// GetLoadFn is a function that returns the load function
123101func (m * Module ) GetLoadFn () func () {
124- return m .loadFn
125- }
126-
127- // SetRegisterRoutesFn is a function that sets the register routes function
128- func (m * Module ) SetRegisterRoutesFn (registerRoutesFn func ()) {
129- m .registerRoutesFn = registerRoutesFn
102+ return m .LoadFn
130103}
131104
132105// GetSubmodules is a function that returns the submodules
133106func (m * Module ) GetSubmodules () * []ModuleWrapper {
134- return & m .submodules
107+ return & m .Submodules
135108}
0 commit comments