This commit is contained in:
Simon Zolin 2020-07-21 19:25:29 +03:00
parent 0cc0aec5b3
commit 117ec4dd43
1 changed files with 3 additions and 2 deletions

View File

@ -12,7 +12,8 @@ import (
) )
func startHTTPServer(data string) (net.Listener, uint16) { func startHTTPServer(data string) (net.Listener, uint16) {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte(data)) _, _ = w.Write([]byte(data))
}) })
@ -21,7 +22,7 @@ func startHTTPServer(data string) (net.Listener, uint16) {
panic(err) panic(err)
} }
go func() { _ = http.Serve(listener, nil) }() go func() { _ = http.Serve(listener, mux) }()
return listener, uint16(listener.Addr().(*net.TCPAddr).Port) return listener, uint16(listener.Addr().(*net.TCPAddr).Port)
} }