Archived
Template
1
0

Adds godoc comments

This commit is contained in:
uberswe
2022-01-09 14:22:43 +01:00
parent 2d3c0df4e5
commit 8c37faf016
30 changed files with 154 additions and 68 deletions

View File

@ -8,11 +8,13 @@ import (
"gorm.io/gorm"
)
// Controller holds all the variables needed for routes to perform their logic
type Controller struct {
db *gorm.DB
config config.Config
}
// New creates a new instance of the routes.Controller
func New(db *gorm.DB, c config.Config) Controller {
return Controller{
db: db,
@ -20,6 +22,7 @@ func New(db *gorm.DB, c config.Config) Controller {
}
}
// PageData holds the default data needed for HTML pages to render
type PageData struct {
Title string
Messages []Message
@ -27,11 +30,13 @@ type PageData struct {
CacheParameter string
}
// Message holds a message which can be rendered as responses on HTML pages
type Message struct {
Type string // success, warning, error, etc.
Content string
}
// isAuthenticated checks if the current user is authenticated or not
func isAuthenticated(c *gin.Context) bool {
_, exists := c.Get(middleware.UserIDKey)
return exists