Fixed files page
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user