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 ( ...@@ -9,6 +9,7 @@ import (
"html" "html"
"io" "io"
"log" "log"
"net"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
...@@ -72,12 +73,21 @@ func Serve(address string, dataDir string) error { ...@@ -72,12 +73,21 @@ func Serve(address string, dataDir string) error {
server.Store(s) 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 { if !Insecure {
err = s.ListenAndServeTLS("", "") err = s.ServeTLS(listener, "", "")
} else { } else {
err = s.ListenAndServe() err = s.Serve(listener)
} }
if err == http.ErrServerClosed { 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