mirkoify
diff --git a/service.go b/service.go
index 03fd218..ec75153 100644
--- a/service.go
+++ b/service.go
@@ -7,8 +7,8 @@
"sort"
"strings"
+ "code.hackerspace.pl/q3k/mirko"
"github.com/gobuffalo/packr"
- "github.com/golang/glog"
"github.com/q3k/statusz"
"vbom.ml/util/sortorder"
@@ -18,21 +18,15 @@
pb "code.hackerspace.pl/q3k/topo/proto/control"
)
-type ServiceConfig struct {
- DebugListen string
-}
-
type Service struct {
- gr *graph.Graph
- stm *state.StateManager
- config ServiceConfig
+ gr *graph.Graph
+ stm *state.StateManager
}
-func NewService(gr *graph.Graph, stm *state.StateManager, c ServiceConfig) *Service {
+func NewService(gr *graph.Graph, stm *state.StateManager) *Service {
return &Service{
- gr: gr,
- stm: stm,
- config: c,
+ gr: gr,
+ stm: stm,
}
}
@@ -110,20 +104,14 @@
</div>
`
-func (s *Service) Run() {
+func (s *Service) Setup(m *mirko.Mirko) {
assets := packr.NewBox("./assets")
- http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(assets)))
- http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- http.Redirect(w, r, "/debug/status", http.StatusSeeOther)
- })
- http.HandleFunc("/debug/graphviz", s.httpHandleGraphviz)
-
+ m.HTTPMux().Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(assets)))
+ m.HTTPMux().HandleFunc("/debug/graphviz", s.httpHandleGraphviz)
statusz.AddStatusPart("Switch Ports", switchportsFragment, s.statusHandleSwitchports)
statusz.AddStatusPart("Topology", topologyFragment, func(ctx context.Context) interface{} {
return nil
})
- glog.Infof("Debug listening on %s....", s.config.DebugListen)
- http.ListenAndServe(s.config.DebugListen, nil)
}
func (s *Service) statusHandleSwitchports(ctx context.Context) interface{} {