31 lines
640 B
Go
31 lines
640 B
Go
package controllers
|
|
|
|
import (
|
|
"kontor-api-gin/pkg/globals"
|
|
"kontor-api-gin/pkg/schema"
|
|
"net/http"
|
|
|
|
"github.com/gin-contrib/sessions"
|
|
"github.com/gin-contrib/slog"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func ListComicsGetHandler(c *gin.Context) {
|
|
session := sessions.Default(c)
|
|
user := session.Get(globals.UserKey)
|
|
logger := slog.Get(c)
|
|
|
|
var comics []schema.Comic
|
|
|
|
result := schema.DB.Find(&comics)
|
|
logger.Info("found Comics", "count", result.RowsAffected)
|
|
c.HTML(http.StatusOK, "comic_comics.tmpl", gin.H{
|
|
"title": "Kontor Comics",
|
|
"version": "0.4.0",
|
|
"content": "Media Files...",
|
|
"comics": comics,
|
|
"user": user,
|
|
})
|
|
|
|
}
|