27 lines
666 B
Go
27 lines
666 B
Go
|
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
|
||
|
}
|