Commit dcb37067 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Allow running the web server on a Unix domain socket.

Thanks to Martin Pépin.
parent b821cd71
......@@ -9,6 +9,7 @@ import (
"html"
"io"
"log"
"net"
"net/http"
"net/url"
"os"
......@@ -72,12 +73,21 @@ func Serve(address string, dataDir string) error {
server.Store(s)
var err error
proto := "tcp"
if strings.HasPrefix(address, "/") {
proto = "unix"
}
listener, err := net.Listen(proto, address)
if err != nil {
return err
}
defer listener.Close()
if !Insecure {
err = s.ListenAndServeTLS("", "")
err = s.ServeTLS(listener, "", "")
} else {
err = s.ListenAndServe()
err = s.Serve(listener)
}
if err == http.ErrServerClosed {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment