From fe0814674f090d8e9326defc0045e5d0c817d9a9 Mon Sep 17 00:00:00 2001 From: Jonas Pinson Date: Tue, 14 May 2024 21:48:06 +0200 Subject: [PATCH] Update server --- rogueserver.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/rogueserver.go b/rogueserver.go index 604df68..6a1beff 100644 --- a/rogueserver.go +++ b/rogueserver.go @@ -72,11 +72,10 @@ func main() { // start web server - handler := prodHandler(mux) - if debug { - handler = debugHandler(mux) + if debug == true { + err = http.Serve(listener, debugHandler(mux)) } else { - err = http.Serve(listener, handler) + err = http.Serve(listener, mux) } if err != nil { log.Fatalf("failed to create http server or server errored: %s", err) @@ -87,19 +86,13 @@ func createListener(proto, addr string) (net.Listener, error) { if proto == "unix" { os.Remove(addr) } - listener, err := net.Listen(proto, addr) if err != nil { return nil, err } - if proto == "unix" { - if err := os.Chmod(addr, 0777); err != nil { - listener.Close() - return nil, err - } + os.Chmod(addr, 0777) } - return listener, nil }