Subrouter fix

This commit is contained in:
2022-01-31 10:02:45 +01:00
parent 1f97caae17
commit 6ac80f8647

View File

@@ -9,7 +9,9 @@ import (
"github.com/gorilla/mux"
"html/template"
"net/http"
"path"
"path/filepath"
"strings"
)
func main() {
@@ -63,7 +65,7 @@ func setupFrontend(r *mux.Router) {
landingpage := template.Must(template.ParseFiles(filepath.Join(config.FrontendDir, "html", "landingpage.gohtml")))
r.PathPrefix("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
if strings.TrimPrefix(r.URL.Path, path.Dir(config.Prefix)) == "/" {
landingpage.Execute(w, config.PageBase)
} else {
server.Error404(w, r)