-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: create Service, Validator, Controller and Module structs (p…
…art IV)
- Loading branch information
1 parent
27250d7
commit 6166b0d
Showing
2 changed files
with
50 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,43 @@ | ||
package factory | ||
|
||
import ( | ||
"github.com/goccy/go-json" | ||
gonethttproute "github.com/ralvarezdev/go-net/http/route" | ||
) | ||
|
||
type ( | ||
// ControllerWrapper is the interface for the route controller | ||
ControllerWrapper interface { | ||
Create(baseRouter gonethttproute.RouterWrapper, path string) error | ||
RegisterRoutes() | ||
RegisterGroups() | ||
gonethttproute.RouterWrapper | ||
} | ||
|
||
// Controller is the struct for the route controller | ||
Controller struct { | ||
gonethttproute.RouterWrapper | ||
} | ||
|
||
// Create creates the controller | ||
func (c *Controller) Create(baseRouter gonethttproute.RouterWrapper, path string) error { | ||
// Check if the base route is nil | ||
if baseRouter == nil { | ||
return gonethttproute.ErrNilRouter | ||
} | ||
|
||
// Set the base route | ||
c.RouterWrapper = baseRouter.NewGroup(path) | ||
|
||
// Register the controller routes and groups | ||
c.RegisterRoutes() | ||
c.RegisterGroups() | ||
return nil | ||
} | ||
|
||
// RegisterRoutes registers the routes | ||
func (c *Controller) RegisterRoutes() {} | ||
|
||
// RegisterGroups registers the groups | ||
func (c *Controller) RegisterGroups() {} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters