Fix routing tree 0.4 (#532)
* Marshal regexp into string for routing tree * Add /lib to dev/static mode switch * Regenerate assets * Remove comment and format anon struct * Simplify configJSON marshaling Make config.Regexp json-Marshalable. * Correctly escape json string * Use value pointer for configJSON
This commit is contained in:
parent
bbd9d2377e
commit
80c85d8dd4
|
@ -14,6 +14,7 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -455,3 +456,8 @@ func (re *Regexp) MarshalYAML() (interface{}, error) {
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalJSON implements the json.Marshaler interface.
|
||||||
|
func (re Regexp) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(re.String())
|
||||||
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
17
web.go
17
web.go
|
@ -59,6 +59,11 @@ func Register(r *route.Router, reloadCh chan<- struct{}, devMode bool) {
|
||||||
r.Get("/", func(w http.ResponseWriter, req *http.Request) {
|
r.Get("/", func(w http.ResponseWriter, req *http.Request) {
|
||||||
http.ServeFile(w, req, "ui/app/index.html")
|
http.ServeFile(w, req, "ui/app/index.html")
|
||||||
})
|
})
|
||||||
|
r.Get("/lib/*filepath", func(w http.ResponseWriter, req *http.Request) {
|
||||||
|
fp := route.Param(route.Context(req), "filepath")
|
||||||
|
log.Infoln("Serving file", fp)
|
||||||
|
http.ServeFile(w, req, fmt.Sprintf("ui/lib/%s", fp))
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
r.Get("/app/*filepath", ihf("app_files",
|
r.Get("/app/*filepath", ihf("app_files",
|
||||||
func(w http.ResponseWriter, req *http.Request) {
|
func(w http.ResponseWriter, req *http.Request) {
|
||||||
|
@ -70,13 +75,13 @@ func Register(r *route.Router, reloadCh chan<- struct{}, devMode bool) {
|
||||||
r.Get("/", ihf("index", func(w http.ResponseWriter, req *http.Request) {
|
r.Get("/", ihf("index", func(w http.ResponseWriter, req *http.Request) {
|
||||||
serveAsset(w, req, "ui/app/index.html")
|
serveAsset(w, req, "ui/app/index.html")
|
||||||
}))
|
}))
|
||||||
|
r.Get("/lib/*filepath", ihf("lib_files",
|
||||||
|
func(w http.ResponseWriter, req *http.Request) {
|
||||||
|
fp := route.Param(route.Context(req), "filepath")
|
||||||
|
serveAsset(w, req, filepath.Join("ui/lib", fp))
|
||||||
|
},
|
||||||
|
))
|
||||||
}
|
}
|
||||||
r.Get("/lib/*filepath", ihf("lib_files",
|
|
||||||
func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
fp := route.Param(route.Context(req), "filepath")
|
|
||||||
serveAsset(w, req, filepath.Join("ui/lib", fp))
|
|
||||||
},
|
|
||||||
))
|
|
||||||
|
|
||||||
r.Get("/metrics", prometheus.Handler().ServeHTTP)
|
r.Get("/metrics", prometheus.Handler().ServeHTTP)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue