1
0

Instead of creating an instance get it as an argument.

This commit is contained in:
Alexander Andreev 2023-05-09 23:36:12 +04:00
parent f8a8d948a4
commit 6ce598d193
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -13,7 +13,6 @@ import (
"git.arav.su/Arav/dwelling-home/web" "git.arav.su/Arav/dwelling-home/web"
"git.arav.su/Arav/justcaptcha/pkg/captcha/inmemdb" "git.arav.su/Arav/justcaptcha/pkg/captcha/inmemdb"
"git.arav.su/Arav/justcaptcha/pkg/dwcaptcha" "git.arav.su/Arav/justcaptcha/pkg/dwcaptcha"
gbsqlite "git.arav.su/Arav/justguestbook/database/sqlite"
"git.arav.su/Arav/justguestbook/guestbook" "git.arav.su/Arav/justguestbook/guestbook"
) )
@ -24,16 +23,9 @@ type Handlers struct {
guestbookPageSize int64 guestbookPageSize int64
} }
func NewHandlers(captchaExpire time.Duration, dbPath, gbOwner string, gbPageSize int64) *Handlers { func NewHandlers(captchaExpire time.Duration, gbOwner string, gbPageSize int64, db guestbook.Guestbook) *Handlers {
gbdb, err := gbsqlite.New(dbPath + "/guestbook.sqlite")
if err != nil {
panic(err)
}
inmemdb.SetExpiry(captchaExpire)
return &Handlers{ return &Handlers{
guestbookDB: gbdb, guestbookDB: db,
captchaExpire: captchaExpire, captchaExpire: captchaExpire,
guestbookOwner: gbOwner, guestbookOwner: gbOwner,
guestbookPageSize: gbPageSize} guestbookPageSize: gbPageSize}