clustvirt/router/router.go
Matthew Stobbs 851ae7a77f implemented a router structure
- keep things localized a bit more
- fixes import cycle
2024-03-21 16:56:24 -06:00

29 lines
638 B
Go

package router
import (
"net/http"
"git.staur.ca/stobbsm/clustvirt/cluster"
"github.com/go-chi/chi/v5"
)
// Types that are shared among routers
// SubRouter defines an interface to be able to add a subrouter to a
// chi router
type SubRouter interface {
MountTo(*cluster.Cluster, chi.Router) error
}
// Route defines a route that should be added to a chi router or
// subrouter
type Route struct {
Method string
Path string
Handler RouteHandler
}
// RouteHandler gets the active cluster for the server to inject into
// the http.HandlerFunc that is then returned
type RouteHandler func(*cluster.Cluster) http.HandlerFunc