51 lines
1008 B
Go
51 lines
1008 B
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*/
|
|
package handler
|
|
|
|
import (
|
|
"mstore/app/logger"
|
|
"mstore/app/maindb"
|
|
"mstore/app/router"
|
|
|
|
"mstore/app/accoper"
|
|
"mstore/app/fileoper"
|
|
"mstore/app/imageoper"
|
|
|
|
yaml "go.yaml.in/yaml/v4"
|
|
)
|
|
|
|
type HandlerParams struct {
|
|
MainDB *maindb.Database
|
|
FileOper *fileoper.Operator
|
|
AccOper *accoper.Operator
|
|
ImageOper *imageoper.Operator
|
|
}
|
|
|
|
type Handler struct {
|
|
mdb *maindb.Database
|
|
logg *logger.Logger
|
|
|
|
fiop *fileoper.Operator
|
|
acop *accoper.Operator
|
|
imop *imageoper.Operator
|
|
}
|
|
|
|
func NewHandler(params *HandlerParams) (*Handler, error) {
|
|
var err error
|
|
hand := &Handler{
|
|
mdb: params.MainDB,
|
|
fiop: params.FileOper,
|
|
acop: params.AccOper,
|
|
imop: params.ImageOper,
|
|
}
|
|
hand.logg = logger.NewLoggerWithSubject("handler")
|
|
return hand, err
|
|
}
|
|
|
|
func (hand *Handler) DumpHeaders(label string, rctx *router.Context) {
|
|
headers := rctx.GetHeaders()
|
|
yamlData, _ := yaml.Marshal(headers)
|
|
hand.logg.Debugf("%s:\n%s\n", label, string(yamlData))
|
|
}
|