mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-27 05:49:04 +01:00
Fix bug with global scope of iteration variable
This commit is contained in:
parent
9df6184e02
commit
efc3e1735b
11
routes.go
11
routes.go
@ -22,7 +22,8 @@ type Route struct {
|
|||||||
|
|
||||||
func setupRoutes(router *mux.Router, routes []Route) {
|
func setupRoutes(router *mux.Router, routes []Route) {
|
||||||
for _, route := range routes {
|
for _, route := range routes {
|
||||||
router.HandleFunc(route.Route, func(rw http.ResponseWriter, r *http.Request) {
|
_route := route
|
||||||
|
router.HandleFunc(_route.Route, func(rw http.ResponseWriter, r *http.Request) {
|
||||||
conf, err := config.GetUIConfig(r)
|
conf, err := config.GetUIConfig(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||||
@ -41,13 +42,13 @@ func setupRoutes(router *mux.Router, routes []Route) {
|
|||||||
infos["admin"] = false
|
infos["admin"] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
infos = route.Setup(infos, r)
|
infos = _route.Setup(infos, r)
|
||||||
if id, ok := infos["id"]; ok {
|
if id, ok := infos["id"]; ok {
|
||||||
route.Title = strings.Replace(route.Title, "<ID>", id.(string), 1)
|
_route.Title = strings.Replace(_route.Title, "<ID>", id.(string), 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.Render(rw, r, route.Template, &templates.Page{
|
templates.Render(rw, r, _route.Template, &templates.Page{
|
||||||
Title: route.Title,
|
Title: _route.Title,
|
||||||
Config: conf,
|
Config: conf,
|
||||||
Infos: infos,
|
Infos: infos,
|
||||||
FilterPresets: buildFilterPresets(r.URL.Query()),
|
FilterPresets: buildFilterPresets(r.URL.Query()),
|
||||||
|
Loading…
Reference in New Issue
Block a user