Serve /index.html on 404

master
breel 2020-08-28 16:16:35 -06:00
parent 4d8f75f7c9
commit 002595a407
1 changed files with 5 additions and 0 deletions

View File

@ -4,9 +4,14 @@ import (
"local/dndex/config"
"local/simpleserve/simpleserve"
"net/http"
"os"
"path"
)
func (rest *REST) static(w http.ResponseWriter, r *http.Request) {
if _, err := os.Stat(path.Join(config.New().StaticRoot, r.URL.Path)); os.IsNotExist(err) {
r.URL.Path = "/"
}
simpleserve.SetContentTypeIfMedia(w, r)
server := http.FileServer(http.Dir(config.New().StaticRoot))
server.ServeHTTP(w, r)