Add custom served folders (#620)

This commit is contained in:
WithoutPants
2020-06-21 22:25:13 +10:00
committed by GitHub
parent d3ababf0a1
commit 77a5b1d814
5 changed files with 78 additions and 0 deletions

View File

@@ -251,6 +251,24 @@ func Start() {
})
startThumbCache()
// Serve static folders
customServedFolders := config.GetCustomServedFolders()
if customServedFolders != nil {
r.HandleFunc("/custom/*", func(w http.ResponseWriter, r *http.Request) {
r.URL.Path = strings.Replace(r.URL.Path, "/custom", "", 1)
// map the path to the applicable filesystem location
var dir string
r.URL.Path, dir = customServedFolders.GetFilesystemLocation(r.URL.Path)
if dir != "" {
http.FileServer(http.Dir(dir)).ServeHTTP(w, r)
} else {
http.NotFound(w, r)
}
})
}
// Serve the web app
r.HandleFunc("/*", func(w http.ResponseWriter, r *http.Request) {
ext := path.Ext(r.URL.Path)