Make https optional.

This commit is contained in:
Jeroen van Veen authored and Juliusz Chroboczek committed 2020-12-27 16:01:29 +01:00
1 parent 2dcfe9ad8d
commit fece9287e2
2 files changed
+15 -4

No files matched your search

+13 -4
View File
@@ -33,6 +33,8 @@ var StaticRoot string
var Redirect string
var Insecure bool
func Serve(address string, dataDir string) error {
http.Handle("/", &fileHandler{http.Dir(StaticRoot)})
http.HandleFunc("/group/", groupHandler)
@@ -68,10 +70,17 @@ func Serve(address string, dataDir string) error {
server.Store(s)
err := s.ListenAndServeTLS(
filepath.Join(dataDir, "cert.pem"),
filepath.Join(dataDir, "key.pem"),
)
var err error
if !Insecure {
err = s.ListenAndServeTLS(
filepath.Join(dataDir, "cert.pem"),
filepath.Join(dataDir, "key.pem"),
)
} else {
err = s.ListenAndServe()
}
if err == http.ErrServerClosed {
return nil
}