mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-27 01:33:37 +00:00
38 lines
880 B
Go
38 lines
880 B
Go
package handlers
|
|
|
|
import (
|
|
"code.tjo.space/mentos1386/zdravko/internal"
|
|
"code.tjo.space/mentos1386/zdravko/internal/models/query"
|
|
"code.tjo.space/mentos1386/zdravko/web/templates/components"
|
|
"github.com/gorilla/sessions"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
var Pages = []*components.Page{
|
|
{Path: "/", Title: "Status"},
|
|
{Path: "/incidents", Title: "Incidents"},
|
|
{Path: "/settings", Title: "Settings"},
|
|
}
|
|
|
|
func GetPageByTitle(pages []*components.Page, title string) *components.Page {
|
|
for _, p := range pages {
|
|
if p.Title == title {
|
|
return p
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type BaseHandler struct {
|
|
db *gorm.DB
|
|
query *query.Query
|
|
config *internal.Config
|
|
|
|
store *sessions.CookieStore
|
|
}
|
|
|
|
func NewBaseHandler(db *gorm.DB, q *query.Query, config *internal.Config) *BaseHandler {
|
|
store := sessions.NewCookieStore([]byte(config.SESSION_SECRET))
|
|
|
|
return &BaseHandler{db, q, config, store}
|
|
}
|