bugfix: use filepath.Join instead of path.Join for crossplatform paths

This commit is contained in:
gutmet 2018-12-09 15:53:42 +01:00
parent cfaa4c3285
commit b5437f35b6

View File

@ -6,18 +6,18 @@ import (
"net/http"
"os"
"os/signal"
"path"
"path/filepath"
)
func viewHandler(root string, w http.ResponseWriter, r *http.Request) {
file := path.Join(root, r.URL.Path[1:])
file := filepath.Join(root, r.URL.Path[1:])
info, err := os.Stat(file)
if err != nil {
fmt.Fprint(w, err)
return
}
if info.IsDir() {
file = path.Join(file, "index.html")
file = filepath.Join(file, "index.html")
}
fmt.Println("GET " + file)
content, _ := goutil.ReadFile(file)