You've already forked golang-base-project
Improves documentation (#13)
* Documents all env variables and adds an example project * Adds godoc comments * Fixed package naming issue
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user