refactor httpd

This commit is contained in:
boyska 2018-11-11 19:18:13 +01:00
parent 7c17c971a0
commit 515e910683
2 changed files with 6 additions and 6 deletions

View file

@ -13,10 +13,11 @@ import (
"gopkg.in/mcuadros/go-syslog.v2/format"
)
// TODO: return a server
func setupHTTP(hub circolog.Hub) {
http.HandleFunc("/", getHTTPHandler(hub))
http.HandleFunc("/ws", getWSHandler(hub))
func setupHTTP(hub circolog.Hub) *http.ServeMux {
mux := http.NewServeMux()
mux.HandleFunc("/", getHTTPHandler(hub))
mux.HandleFunc("/ws", getWSHandler(hub))
return mux
}
func parseParameterL(r *http.Request) (int, error) {

View file

@ -59,8 +59,7 @@ func main() {
os.Exit(1)
}
setupHTTP(hub)
httpServer := http.Server{Handler: nil}
httpServer := http.Server{Handler: setupHTTP(hub)}
if *querySocket != "" {
fmt.Printf("Binding address `%s` [http]\n", *querySocket)
unixListener, err := net.Listen("unix", *querySocket)