Skip to content

Commit

Permalink
simplier way to pass data to template
Browse files Browse the repository at this point in the history
  • Loading branch information
f1mishutka committed Apr 10, 2024
1 parent c2f128c commit 421fbc8
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions app/web_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,12 @@ func BuildWebRouter(r *gin.Engine) {
r.GET("/", WebIndex)
}

type indexData struct {
Global interface{}
AppInfo *goappbase.AppBase
Auth bool
}

func WebIndex(c *gin.Context) {
session := sessions.Default(c)

data := &indexData{
AppInfo: App,
Auth: session.Get("auth") == true,
}

c.HTML(http.StatusOK, "index.html", data)
//c.HTML(http.StatusOK, "index.html", data)
c.HTML(http.StatusOK, "index.html", gin.H{
"AppInfo": App,
"Auth": session.Get("auth") == true,
})
}

0 comments on commit 421fbc8

Please sign in to comment.