Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTTP handler routing #115

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading