Switch from routes to self-registering handlers to group related routes.
This commit is contained in:
parent
8ca11c90e1
commit
59c10f1874
19 changed files with 719 additions and 717 deletions
27
pkg/handlers/handlers.go
Normal file
27
pkg/handlers/handlers.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/mikestefanello/pagoda/pkg/services"
|
||||
)
|
||||
|
||||
var handlers []Handler
|
||||
|
||||
// Handler handles one or more HTTP routes
|
||||
type Handler interface {
|
||||
// Routes allows for self-registration of HTTP routes on the router
|
||||
Routes(g *echo.Group)
|
||||
|
||||
// Init provides the service container to initialize
|
||||
Init(*services.Container) error
|
||||
}
|
||||
|
||||
// Register registers a handler
|
||||
func Register(h Handler) {
|
||||
handlers = append(handlers, h)
|
||||
}
|
||||
|
||||
// GetHandlers returns all handlers
|
||||
func GetHandlers() []Handler {
|
||||
return handlers
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue