Switch from routes to self-registering handlers to group related routes.

This commit is contained in:
mikestefanello 2024-06-09 12:31:30 -04:00
parent 8ca11c90e1
commit 59c10f1874
19 changed files with 719 additions and 717 deletions

27
pkg/handlers/handlers.go Normal file
View 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
}