Files
Website/backend/handlers/themes_handler/dependencies.go
T

29 lines
896 B
Go

package themes_handler
import (
"net/http"
"time"
"autolibrary.top/webserver/backend/services/theme_files"
"autolibrary.top/webserver/backend/services/themes_service"
"autolibrary.top/webserver/backend/services/users_service"
"autolibrary.top/webserver/config"
"gorm.io/gorm"
)
// Handler shares explicit dependencies across the marketplace HTTP handlers.
// A separate instance can be constructed for each database and storage root.
type Handler struct {
DB *gorm.DB
Config *config.Config
Files *theme_files.Store
Users *users_service.Cache
HTTP *http.Client
Themes *themes_service.Service
}
func New(db *gorm.DB, cfg *config.Config, files *theme_files.Store, users *users_service.Cache) *Handler {
return &Handler{DB: db, Config: cfg, Files: files, Users: users, Themes: &themes_service.Service{DB: db, Files: files}, HTTP: &http.Client{Timeout: 15 * time.Second}}
}