1
0
Fork 0
forked from boyska/circolog

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" "gopkg.in/mcuadros/go-syslog.v2/format"
) )
// TODO: return a server func setupHTTP(hub circolog.Hub) *http.ServeMux {
func setupHTTP(hub circolog.Hub) { mux := http.NewServeMux()
http.HandleFunc("/", getHTTPHandler(hub)) mux.HandleFunc("/", getHTTPHandler(hub))
http.HandleFunc("/ws", getWSHandler(hub)) mux.HandleFunc("/ws", getWSHandler(hub))
return mux
} }
func parseParameterL(r *http.Request) (int, error) { func parseParameterL(r *http.Request) (int, error) {

View file

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