In production mode, embed static content
This commit is contained in:
parent
0876fc3c2e
commit
deb4ff03ca
9
main.go
9
main.go
@ -5,7 +5,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var mux = http.NewServeMux()
|
var mux = http.NewServeMux()
|
||||||
@ -55,12 +54,8 @@ func main() {
|
|||||||
log.Println("Registering handlers...")
|
log.Println("Registering handlers...")
|
||||||
authFunc := func(r *http.Request) *User { return Authenticate(*htpasswd, r) }
|
authFunc := func(r *http.Request) *User { return Authenticate(*htpasswd, r) }
|
||||||
|
|
||||||
staticDir, _ := filepath.Abs("static")
|
if err := sanitizeStaticOptions(); err != nil {
|
||||||
if _, err := os.Stat(staticDir); os.IsNotExist(err) {
|
log.Fatal(err)
|
||||||
staticDir, _ = filepath.Abs(filepath.Join(filepath.Dir(os.Args[0]), "static"))
|
|
||||||
if _, err := os.Stat(staticDir); os.IsNotExist(err) {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user