mirror of
https://github.com/rancher/steve.git
synced 2025-08-31 23:20:56 +00:00
Add UI back to steve
This commit is contained in:
38
pkg/ui/routes.go
Normal file
38
pkg/ui/routes.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
func New(path string) http.Handler {
|
||||
vue := NewUIHandler(&Options{
|
||||
Path: func() string {
|
||||
if path == "" {
|
||||
return defaultPath
|
||||
}
|
||||
return path
|
||||
},
|
||||
})
|
||||
|
||||
router := mux.NewRouter()
|
||||
router.UseEncodedPath()
|
||||
|
||||
router.Handle("/", http.RedirectHandler("/dashboard/", http.StatusFound))
|
||||
router.Handle("/dashboard", http.RedirectHandler("/dashboard/", http.StatusFound))
|
||||
router.Handle("/dashboard/", vue.IndexFile())
|
||||
router.Handle("/favicon.png", vue.ServeFaviconDashboard())
|
||||
router.Handle("/favicon.ico", vue.ServeFaviconDashboard())
|
||||
router.PathPrefix("/dashboard/").Handler(vue.IndexFileOnNotFound())
|
||||
router.PathPrefix("/k8s/clusters/local").HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||
url := strings.TrimPrefix(req.URL.Path, "/k8s/clusters/local")
|
||||
if url == "" {
|
||||
url = "/"
|
||||
}
|
||||
http.Redirect(rw, req, url, http.StatusFound)
|
||||
})
|
||||
|
||||
return router
|
||||
}
|
Reference in New Issue
Block a user