mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 08:57:25 +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) {
|
||||
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)
|
||||
if err != nil {
|
||||
http.Error(rw, err.Error(), http.StatusInternalServerError)
|
||||
@ -41,13 +42,13 @@ func setupRoutes(router *mux.Router, routes []Route) {
|
||||
infos["admin"] = false
|
||||
}
|
||||
|
||||
infos = route.Setup(infos, r)
|
||||
infos = _route.Setup(infos, r)
|
||||
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{
|
||||
Title: route.Title,
|
||||
templates.Render(rw, r, _route.Template, &templates.Page{
|
||||
Title: _route.Title,
|
||||
Config: conf,
|
||||
Infos: infos,
|
||||
FilterPresets: buildFilterPresets(r.URL.Query()),
|
||||
|
Loading…
Reference in New Issue
Block a user