2024-02-11 19:28:00 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"code.tjo.space/mentos1386/zdravko/internal"
|
|
|
|
"code.tjo.space/mentos1386/zdravko/internal/models/query"
|
2024-02-11 22:48:37 +00:00
|
|
|
"github.com/gorilla/sessions"
|
2024-02-11 19:28:00 +00:00
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type BaseHandler struct {
|
|
|
|
db *gorm.DB
|
|
|
|
query *query.Query
|
|
|
|
config *internal.Config
|
2024-02-11 22:48:37 +00:00
|
|
|
|
|
|
|
store *sessions.CookieStore
|
2024-02-11 19:28:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewBaseHandler(db *gorm.DB, q *query.Query, config *internal.Config) *BaseHandler {
|
2024-02-11 22:48:37 +00:00
|
|
|
store := sessions.NewCookieStore([]byte(config.SESSION_SECRET))
|
|
|
|
|
|
|
|
return &BaseHandler{db, q, config, store}
|
2024-02-11 19:28:00 +00:00
|
|
|
}
|