Make all files and directories in the config absolute

This commit is contained in:
2025-01-19 08:59:36 +01:00
parent 5552e6d2eb
commit 5d251c3659
5 changed files with 43 additions and 48 deletions

View File

@ -1,9 +1,7 @@
package calls
import (
"log"
"net/http"
"path/filepath"
b "streifling.com/jason/cpolis/cmd/backend"
)
@ -14,13 +12,6 @@ func ServeAtomFeed(c *b.Config) http.HandlerFunc {
return
}
absFilepath, err := filepath.Abs(c.AtomFile)
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.ServeFile(w, r, absFilepath)
http.ServeFile(w, r, c.AtomFile)
}
}

View File

@ -1,7 +1,6 @@
package calls
import (
"log"
"net/http"
"path/filepath"
@ -17,13 +16,6 @@ func ServeImage(c *b.Config, s map[string]*f.Session) http.HandlerFunc {
}
}
absFilepath, err := filepath.Abs(c.PicsDir)
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
http.ServeFile(w, r, absFilepath+"/"+r.PathValue("pic"))
http.ServeFile(w, r, filepath.Join(c.PicsDir, r.PathValue("pic")))
}
}