Use mux for http server

Without it can not start multiple http
server instances for unit tests
This commit is contained in:
Zoltán Papp 2024-05-29 16:11:58 +02:00
parent 6d627f1923
commit 7cc3964a4d

View File

@ -36,10 +36,12 @@ func NewListener(address string) listener.Listener {
// Listen todo: prevent multiple call
func (l *Listener) Listen(acceptFn func(conn net.Conn)) error {
l.acceptFn = acceptFn
http.HandleFunc("/", l.onAccept)
mux := http.NewServeMux()
mux.HandleFunc("/", l.onAccept)
l.server = &http.Server{
Addr: l.address,
Addr: l.address,
Handler: mux,
}
log.Infof("WS server is listening on address: %s", l.address)