From c19afa94a12c8facac4cb6316da3248fc1b27cb0 Mon Sep 17 00:00:00 2001 From: Sinuhe Tellez Date: Sat, 30 May 2020 12:45:33 -0400 Subject: [PATCH] we dont need filepath package --- main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 7e09bfa..a9a2477 100644 --- a/main.go +++ b/main.go @@ -26,8 +26,8 @@ import ( "log" "mime" "net/http" - "net/url" "os" + "path" "path/filepath" "time" @@ -80,21 +80,21 @@ func startValues() string { } func handler(w http.ResponseWriter, req *http.Request) error { - fpath := filepath.Join(*dirRoot, req.URL.Path) + fPath := path.Join(*dirRoot, req.URL.Path) - log.Printf("fpath:'%s'", fpath) + log.Printf("fPath:'%s'", fPath) - fi, err := os.Stat(fpath) + fi, err := os.Stat(fPath) if err != nil { return err } if isFile(fi) { - http.ServeFile(w, req, fpath) + http.ServeFile(w, req, fPath) return nil } - content, err := getContent(req, fpath) + content, err := getContent(req, fPath) if err != nil { return err } @@ -127,7 +127,7 @@ func makeFeed(dirpath string, req *http.Request) atom.Feed { fis, _ := ioutil.ReadDir(dirpath) for _, fi := range fis { - pathType := getPathType(filepath.Join(dirpath, fi.Name())) + pathType := getPathType(path.Join(dirpath, fi.Name())) feedBuilder = feedBuilder. AddEntry(opds.EntryBuilder. ID(req.URL.Path + fi.Name()). @@ -167,7 +167,7 @@ func getType(name string, pathType int) string { } func getHref(req *http.Request, name string) string { - return filepath.Join(req.URL.RequestURI(), url.PathEscape(name)) + return path.Join(req.URL.RequestURI(), name) } const (