In production mode, embed static content

This commit is contained in:
nemunaire 2019-09-02 15:41:37 +02:00
parent 0876fc3c2e
commit deb4ff03ca
1 changed files with 2 additions and 7 deletions

View File

@ -5,7 +5,6 @@ import (
"log"
"net/http"
"os"
"path/filepath"
)
var mux = http.NewServeMux()
@ -55,12 +54,8 @@ func main() {
log.Println("Registering handlers...")
authFunc := func(r *http.Request) *User { return Authenticate(*htpasswd, r) }
staticDir, _ := filepath.Abs("static")
if _, err := os.Stat(staticDir); os.IsNotExist(err) {
staticDir, _ = filepath.Abs(filepath.Join(filepath.Dir(os.Args[0]), "static"))
if _, err := os.Stat(staticDir); os.IsNotExist(err) {
log.Fatal(err)
}
if err := sanitizeStaticOptions(); err != nil {
log.Fatal(err)
}
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {