Fixed files page

This commit is contained in:
Caleb Gardner
2024-08-07 03:36:15 -05:00
parent 1e9eeb25d1
commit da2db3ea9a
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ import (
"path/filepath" "path/filepath"
) )
const fileElement = "<p><a href='https://darkstorm.tech/%v/'>%v</a></p>" const fileElement = "<p><a href='https://darkstorm.tech%v'>%v</a></p>"
func filesRequest(w http.ResponseWriter, r *http.Request) { func filesRequest(w http.ResponseWriter, r *http.Request) {
partPath := filepath.Clean(r.URL.Path) partPath := filepath.Clean(r.URL.Path)
@@ -38,7 +38,7 @@ func filesRequest(w http.ResponseWriter, r *http.Request) {
if f.IsDir() { if f.IsDir() {
continue continue
} }
pageContent += fmt.Sprintf(fileElement, partPath, f.Name()) pageContent += fmt.Sprintf(fileElement, filepath.Join(partPath, f.Name()), f.Name())
} }
} else { } else {
http.ServeFile(w, r, path) http.ServeFile(w, r, path)
+1 -1
View File
@@ -88,7 +88,7 @@ func setupBackend(mux *http.ServeMux) {
func setupWebsite(mux *http.ServeMux) { func setupWebsite(mux *http.ServeMux) {
url, _ := url.Parse("https://localhost:30000") url, _ := url.Parse("https://localhost:30000")
mux.Handle("rpg.darkstorm.tech/", httputil.NewSingleHostReverseProxy(url)) mux.Handle("rpg.darkstorm.tech/", httputil.NewSingleHostReverseProxy(url))
mux.HandleFunc("GET /files", filesRequest) mux.HandleFunc("GET /files/{w...}", filesRequest)
mux.HandleFunc("GET /portfolio", portfolioRequest) mux.HandleFunc("GET /portfolio", portfolioRequest)
mux.HandleFunc("/", mainHandle) mux.HandleFunc("/", mainHandle)
} }