Skip to content

Commit 4c9dab8

Browse files
committed
Fix HTTP handler routing
1 parent 7c0cd02 commit 4c9dab8

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

mqtt/listeners/http_sysinfo.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import (
2020
// HTTPStats is a listener for presenting the server $SYS stats on a JSON http endpoint.
2121
type HTTPStats struct {
2222
sync.RWMutex
23-
id string // the internal id of the listener
24-
address string // the network address to bind to
25-
config *Config // configuration values for the listener
26-
listen *http.Server // the http server
27-
sysInfo *system.Info // pointers to the server data
28-
end uint32 // ensure the close methods are only called once
23+
id string // the internal id of the listener
24+
address string // the network address to bind to
25+
config *Config // configuration values for the listener
26+
listen *http.Server // the http server
27+
sysInfo *system.Info // pointers to the server data
28+
end uint32 // ensure the close methods are only called once
2929
handlers Handlers
3030
}
3131

@@ -79,6 +79,9 @@ func (l *HTTPStats) Protocol() string {
7979
// Init initializes the listener.
8080
func (l *HTTPStats) Init(_ *slog.Logger) error {
8181
mux := http.NewServeMux()
82+
for path, handler := range l.handlers {
83+
mux.HandleFunc(path, handler)
84+
}
8285
mux.HandleFunc("/", l.jsonHandler)
8386
l.listen = &http.Server{
8487
ReadTimeout: 5 * time.Second,

0 commit comments

Comments
 (0)