Fix bug where path vars go lost
This commit is contained in:
12
ui/serve.go
12
ui/serve.go
@@ -11,7 +11,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
resources "github.com/cookieo9/resources-go"
|
resources "github.com/cookieo9/resources-go"
|
||||||
"github.com/gorilla/mux"
|
|
||||||
|
|
||||||
"github.com/safing/portbase/api"
|
"github.com/safing/portbase/api"
|
||||||
"github.com/safing/portbase/log"
|
"github.com/safing/portbase/log"
|
||||||
@@ -41,7 +40,7 @@ func ServeBundle(defaultModuleName string) func(w http.ResponseWriter, r *http.R
|
|||||||
|
|
||||||
// log.Tracef("ui: request for %s", r.RequestURI)
|
// log.Tracef("ui: request for %s", r.RequestURI)
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := api.GetMuxVars(r)
|
||||||
moduleName, ok := vars["moduleName"]
|
moduleName, ok := vars["moduleName"]
|
||||||
if !ok {
|
if !ok {
|
||||||
moduleName = defaultModuleName
|
moduleName = defaultModuleName
|
||||||
@@ -98,8 +97,13 @@ func ServeBundle(defaultModuleName string) func(w http.ResponseWriter, r *http.R
|
|||||||
func ServeFileFromBundle(w http.ResponseWriter, r *http.Request, bundleName string, bundle *resources.BundleSequence, path string) {
|
func ServeFileFromBundle(w http.ResponseWriter, r *http.Request, bundleName string, bundle *resources.BundleSequence, path string) {
|
||||||
readCloser, err := bundle.Open(path)
|
readCloser, err := bundle.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Tracef("ui: error opening module %s: %s", bundleName, err)
|
if err == resources.ErrNotFound {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
log.Tracef("ui: requested resource \"%s\" not found in bundle %s: %s", path, bundleName, err)
|
||||||
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
} else {
|
||||||
|
log.Tracef("ui: error opening module %s: %s", bundleName, err)
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user