indiescrobble/controllers/index.go

30 lines
592 B
Go
Raw Normal View History

package controllers
import (
"net/http"
2022-02-13 15:49:22 +00:00
"git.jamesravey.me/ravenscroftj/indiescrobble/models"
"git.jamesravey.me/ravenscroftj/indiescrobble/scrobble"
"github.com/gin-gonic/gin"
)
func Index(c *gin.Context) {
2022-02-13 15:49:22 +00:00
// this is an authed endpoint so 'user' must be set and if not panicking is fair
currentUser, exists := c.Get("user")
var user *models.BaseUser
if exists {
user = currentUser.(*models.BaseUser)
}else{
user = nil
}
c.HTML(http.StatusOK, "index.tmpl", gin.H{
2022-02-13 15:49:22 +00:00
"title": "test",
"user": user,
"scrobbleTypes": scrobble.ScrobbleTypeNames,
})
}