kg: do not export handlers

This commit is contained in:
Steffen Vogel 2021-07-16 11:54:00 +02:00
parent cd96616a91
commit cfb680e99a
2 changed files with 6 additions and 6 deletions

View File

@ -26,12 +26,12 @@ import (
"github.com/squat/kilo/pkg/mesh" "github.com/squat/kilo/pkg/mesh"
) )
type GraphHandler struct { type graphHandler struct {
mesh *mesh.Mesh mesh *mesh.Mesh
granularity mesh.Granularity granularity mesh.Granularity
} }
func (h *GraphHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h *graphHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ns, err := h.mesh.Nodes().List() ns, err := h.mesh.Nodes().List()
if err != nil { if err != nil {
http.Error(w, fmt.Sprintf("failed to list nodes: %v", err), 500) http.Error(w, fmt.Sprintf("failed to list nodes: %v", err), 500)
@ -124,9 +124,9 @@ func (h *GraphHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Write(output) w.Write(output)
} }
type HealthHandler struct { type healthHandler struct {
} }
func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) { func (h *healthHandler) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
} }

View File

@ -196,8 +196,8 @@ func Main() error {
{ {
// Run the HTTP server. // Run the HTTP server.
mux := http.NewServeMux() mux := http.NewServeMux()
mux.Handle("/health", &HealthHandler{}) mux.Handle("/health", &healthHandler{})
mux.Handle("/graph", &GraphHandler{m, gr}) mux.Handle("/graph", &graphHandler{m, gr})
mux.Handle("/metrics", promhttp.HandlerFor(r, promhttp.HandlerOpts{})) mux.Handle("/metrics", promhttp.HandlerFor(r, promhttp.HandlerOpts{}))
l, err := net.Listen("tcp", *listen) l, err := net.Listen("tcp", *listen)
if err != nil { if err != nil {