Serve /index.html on 404
parent
4d8f75f7c9
commit
002595a407
|
|
@ -4,9 +4,14 @@ import (
|
||||||
"local/dndex/config"
|
"local/dndex/config"
|
||||||
"local/simpleserve/simpleserve"
|
"local/simpleserve/simpleserve"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (rest *REST) static(w http.ResponseWriter, r *http.Request) {
|
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)
|
simpleserve.SetContentTypeIfMedia(w, r)
|
||||||
server := http.FileServer(http.Dir(config.New().StaticRoot))
|
server := http.FileServer(http.Dir(config.New().StaticRoot))
|
||||||
server.ServeHTTP(w, r)
|
server.ServeHTTP(w, r)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue