indiescrobble/controllers/index.go

30 lines
601 B
Go

package controllers
import (
"net/http"
"git.jamesravey.me/ravenscroftj/indiescrobble/models"
"git.jamesravey.me/ravenscroftj/indiescrobble/services/scrobble"
"github.com/gin-gonic/gin"
)
func Index(c *gin.Context) {
// 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{
"title": "test",
"user": user,
"scrobbleTypes": scrobble.ScrobbleTypeNames,
})
}