diff --git a/internal/http/handlers.go b/internal/http/handlers.go index 291a960..7521503 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -9,23 +9,34 @@ import ( "git.arav.top/Arav/dwelling-home/pkg/servicestat" "git.arav.top/Arav/dwelling-home/pkg/util" "git.arav.top/Arav/dwelling-home/web" + gbsqlite "git.arav.top/Arav/justguestbook/database/sqlite" ) type Handlers struct { + guestbookDB *gbsqlite.SQLiteDatabase captchaExpire time.Duration databasesPath string guestbookOwner string guestbookPageSize int64 } -func NewHandlers(captchaExpire time.Duration, dbPath, gbOwner string, gbPageSize int) *Handlers { +func NewHandlers(captchaExpire time.Duration, dbPath, gbOwner string, gbPageSize int64) *Handlers { + gbdb, err := gbsqlite.New(dbPath + "/guestbook.sqlite") + if err != nil { + panic(err) + } + return &Handlers{ + guestbookDB: gbdb, captchaExpire: captchaExpire, - databasesPath: dbPath, guestbookOwner: gbOwner, guestbookPageSize: gbPageSize} } +func (h *Handlers) CloseDB() { + h.guestbookDB.Close() +} + func (h *Handlers) AssetsFS() http.FileSystem { return web.Assets() }