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"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func viewHandler(root string, w http.ResponseWriter, r *http.Request) {
|
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)
|
info, err := os.Stat(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprint(w, err)
|
fmt.Fprint(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
file = path.Join(file, "index.html")
|
file = filepath.Join(file, "index.html")
|
||||||
}
|
}
|
||||||
fmt.Println("GET " + file)
|
fmt.Println("GET " + file)
|
||||||
content, _ := goutil.ReadFile(file)
|
content, _ := goutil.ReadFile(file)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user