dashboard: use last path item to handle TP number selection
This commit is contained in:
parent
6086b82181
commit
8d55ecc3af
3 changed files with 39 additions and 14 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
@ -38,11 +39,14 @@ func init() {
|
|||
Router().GET("/dashboard/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
http.ServeFile(w, r, path.Join(StaticDir, "dashboard.html"))
|
||||
})
|
||||
Router().GET("/dashboard/css/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/dashboard")
|
||||
serveStaticAsset(w, r)
|
||||
Router().GET("/dashboard/:where", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
if _, err := strconv.ParseInt(string(ps.ByName("where")), 10, 64); err != nil {
|
||||
http.NotFound(w, r)
|
||||
} else {
|
||||
http.ServeFile(w, r, path.Join(StaticDir, "dashboard.html"))
|
||||
}
|
||||
})
|
||||
Router().GET("/dashboard/js/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
Router().GET("/dashboard/:where/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/dashboard")
|
||||
serveStaticAsset(w, r)
|
||||
})
|
||||
|
|
Reference in a new issue