docs path fix in serve

This commit is contained in:
2026-02-27 15:52:50 +01:00
parent f9cb923639
commit a11d98fb34
3 changed files with 12 additions and 4 deletions
+9 -2
View File
@@ -48,7 +48,7 @@ func (c *DocsController) ServeDocs(w http.ResponseWriter, r *http.Request) {
return
}
docs_base_dir := c.fileService.GetPath(targetRelease.DocsFolderPath)
docs_base_dir := targetRelease.DocsFolderPath
if _, err := os.Stat(docs_base_dir); os.IsNotExist(err) {
http.Error(w, fmt.Sprintf("Documentation for '%s' version '%s' not found.", name, version), http.StatusNotFound)
@@ -58,6 +58,13 @@ func (c *DocsController) ServeDocs(w http.ResponseWriter, r *http.Request) {
return
}
fs := http.StripPrefix(fmt.Sprintf("/docs/%s/%s", name, version), http.FileServer(http.Dir(docs_base_dir)))
prefix := fmt.Sprintf("/docs/%s/%s", name, version)
if r.URL.Path == prefix {
http.Redirect(w, r, prefix+"/", http.StatusMovedPermanently)
return
}
fs := http.StripPrefix(prefix, http.FileServer(http.Dir(docs_base_dir)))
fs.ServeHTTP(w, r)
}