Skip to content

Commit

Permalink
Fix HTTP handler routing
Browse files Browse the repository at this point in the history
  • Loading branch information
ohkinozomu committed Aug 8, 2024
1 parent 7c0cd02 commit 4c9dab8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mqtt/listeners/http_sysinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import (
// HTTPStats is a listener for presenting the server $SYS stats on a JSON http endpoint.
type HTTPStats struct {
sync.RWMutex
id string // the internal id of the listener
address string // the network address to bind to
config *Config // configuration values for the listener
listen *http.Server // the http server
sysInfo *system.Info // pointers to the server data
end uint32 // ensure the close methods are only called once
id string // the internal id of the listener
address string // the network address to bind to
config *Config // configuration values for the listener
listen *http.Server // the http server
sysInfo *system.Info // pointers to the server data
end uint32 // ensure the close methods are only called once
handlers Handlers
}

Expand Down Expand Up @@ -79,6 +79,9 @@ func (l *HTTPStats) Protocol() string {
// Init initializes the listener.
func (l *HTTPStats) Init(_ *slog.Logger) error {
mux := http.NewServeMux()
for path, handler := range l.handlers {
mux.HandleFunc(path, handler)
}
mux.HandleFunc("/", l.jsonHandler)
l.listen = &http.Server{
ReadTimeout: 5 * time.Second,
Expand Down

0 comments on commit 4c9dab8

Please sign in to comment.