diff --git a/http/controller.docs.go b/http/controller.docs.go index 516af4c..5ccabc2 100644 --- a/http/controller.docs.go +++ b/http/controller.docs.go @@ -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) } diff --git a/http/router.go b/http/router.go index 99d5f82..955b2a6 100755 --- a/http/router.go +++ b/http/router.go @@ -47,6 +47,7 @@ func (r *Router) Init() *chi.Mux { router.Get("/download/{name}/{version}/cartridge", r.downloadController.GetCartridge) router.Get("/play/{name}/{version}", r.playController.Play) router.Get("/play/{name}/{version}/content*", r.playController.ServeContent) + router.Get("/docs/{name}/{version}", r.docsController.ServeDocs) router.Get("/docs/{name}/{version}/*", r.docsController.ServeDocs) fs := http.FileServer(http.Dir("assets")) diff --git a/http/views/software/show.html b/http/views/software/show.html index 0301f06..92c85c9 100644 --- a/http/views/software/show.html +++ b/http/views/software/show.html @@ -18,7 +18,7 @@
{{if .WebPlayableRelease.DocsFolderPath}} - Docs + Docs {{end}}
@@ -89,7 +89,7 @@ Cartridge {{if .DocsFolderPath}} - Docs + Docs {{end}}