go/svc: finish porting services to Bazel
The following services were never ported:
- cmc-proxy
- arista-proxy
- m6220-proxy
- topo
They now build.
Change-Id: I0688bfe43cdff946e6662e21969ef539382c0e86
diff --git a/go/svc/topo/service.go b/go/svc/topo/service.go
index 571eb97..fbbee92 100644
--- a/go/svc/topo/service.go
+++ b/go/svc/topo/service.go
@@ -7,13 +7,15 @@
"sort"
"strings"
+ "vbom.ml/util/sortorder"
+
"code.hackerspace.pl/hscloud/go/mirko"
- ipb "code.hackerspace.pl/hscloud/go/proto/infra"
"code.hackerspace.pl/hscloud/go/statusz"
+ ipb "code.hackerspace.pl/hscloud/proto/infra"
+
+ "code.hackerspace.pl/hscloud/go/svc/topo/assets"
"code.hackerspace.pl/hscloud/go/svc/topo/graph"
"code.hackerspace.pl/hscloud/go/svc/topo/state"
- "github.com/gobuffalo/packr"
- "vbom.ml/util/sortorder"
)
type Service struct {
@@ -103,8 +105,19 @@
`
func (s *Service) Setup(m *mirko.Mirko) {
- assets := packr.NewBox("./assets")
- m.HTTPMux().Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(assets)))
+ m.HTTPMux().Handle("/assets/", http.StripPrefix("/assets/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ data, ok := assets.Data[r.RequestURI]
+ if !ok {
+ http.NotFound(w, r)
+ return
+ }
+
+ if strings.HasSuffix(r.RequestURI, ".js") {
+ w.Header().Set("Content-Type", "text/javascript")
+ }
+
+ w.Write(data)
+ })))
m.HTTPMux().HandleFunc("/debug/graphviz", s.httpHandleGraphviz)
statusz.AddStatusPart("Switch Ports", switchportsFragment, s.statusHandleSwitchports)
statusz.AddStatusPart("Topology", topologyFragment, func(ctx context.Context) interface{} {