mirror of
https://github.com/jech/galene.git
synced 2024-11-09 18:25:58 +01:00
Allow running the web server on a Unix domain socket.
Thanks to Martin Pépin.
This commit is contained in:
parent
b821cd71a9
commit
dcb370677f
1 changed files with 13 additions and 3 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue