Archived
Template
1
0

Improves documentation (#13)

* Documents all env variables and adds an example project

* Adds godoc comments

* Fixed package naming issue
This commit is contained in:
Markus Tenghamn
2022-01-09 14:42:03 +01:00
committed by GitHub
parent 5d01717111
commit e586933a6b
31 changed files with 248 additions and 78 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