bugfix: use filepath.Join instead of path.Join for crossplatform paths
This commit is contained in:
parent
cfaa4c3285
commit
b5437f35b6
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user