Update server

This commit is contained in:
Jonas Pinson 2024-05-14 21:48:06 +02:00
parent 762104d7f0
commit fe0814674f

View File

@ -72,11 +72,10 @@ func main() {
// start web server // start web server
handler := prodHandler(mux) if debug == true {
if debug { err = http.Serve(listener, debugHandler(mux))
handler = debugHandler(mux)
} else { } else {
err = http.Serve(listener, handler) err = http.Serve(listener, mux)
} }
if err != nil { if err != nil {
log.Fatalf("failed to create http server or server errored: %s", err) 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" { if proto == "unix" {
os.Remove(addr) os.Remove(addr)
} }
listener, err := net.Listen(proto, addr) listener, err := net.Listen(proto, addr)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if proto == "unix" { if proto == "unix" {
if err := os.Chmod(addr, 0777); err != nil { os.Chmod(addr, 0777)
listener.Close()
return nil, err
}
} }
return listener, nil return listener, nil
} }