Subrouter fix
This commit is contained in:
4
main.go
4
main.go
@@ -9,7 +9,9 @@ import (
|
|||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -63,7 +65,7 @@ func setupFrontend(r *mux.Router) {
|
|||||||
landingpage := template.Must(template.ParseFiles(filepath.Join(config.FrontendDir, "html", "landingpage.gohtml")))
|
landingpage := template.Must(template.ParseFiles(filepath.Join(config.FrontendDir, "html", "landingpage.gohtml")))
|
||||||
|
|
||||||
r.PathPrefix("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
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)
|
landingpage.Execute(w, config.PageBase)
|
||||||
} else {
|
} else {
|
||||||
server.Error404(w, r)
|
server.Error404(w, r)
|
||||||
|
|||||||
Reference in New Issue
Block a user