Files
template-vitrine/backend/internal/modules/ldmod/service.go
T
Xor290 4d1a5b9629
ci-api / test (push) Successful in 22m31s
ci-web / test (push) Successful in 11m35s
chore: build
2026-10-23 16:51:57 +02:00

32 lines
805 B
Go

package ldmod
import (
"context"
"errors"
)
var ErrInvalidTheme = errors.New("default_theme must be 'light' or 'dark'")
type Service struct {
repo Repository
}
func NewService(repo Repository) *Service {
return &Service{repo: repo}
}
func (s *Service) Get(ctx context.Context) (*LDMod, error) {
return s.repo.Get(ctx)
}
// Update remplace les deux réglages. default_theme n'a de sens que parmi les
// deux thèmes que le frontend sait rendre (voir theme/ThemeContext.tsx côté
// frontend) : le client ne doit jamais pouvoir pousser une valeur arbitraire
// qui ferait planter le rendu.
func (s *Service) Update(ctx context.Context, m *LDMod) (*LDMod, error) {
if m.DefaultTheme != ThemeLight && m.DefaultTheme != ThemeDark {
return nil, ErrInvalidTheme
}
return s.repo.Update(ctx, m)
}