go-urlsh/internal/api/model.go

27 lines
666 B
Go
Raw Permalink Normal View History

2024-09-30 13:19:01 +02:00
package api
import (
"code.lila.network/adoralaura/go-urlsh/internal/config"
"github.com/rs/zerolog"
"github.com/uptrace/bun"
)
// APIRouteManager is a model that provides db, logger and config access
// to API routes
type APIRouteManager struct {
db *bun.DB
logger *zerolog.Logger
config *config.Config
}
// NewAPIRouteManager creates a new Instance of an APIRouteManager
// and initializes it with the given DB, Logger and Config
func NewAPIRouteManager(db *bun.DB, logger *zerolog.Logger, config *config.Config) *APIRouteManager {
manager := new(APIRouteManager)
manager.db = db
manager.logger = logger
manager.config = config
return manager
}